Record Class Solution<E extends Equation>
java.lang.Object
java.lang.Record
io.github.andreipunko.math.pde.solver.Solution<E>
- Type Parameters:
E- the type of equation that was solved- Record Components:
equation- the partial differential equation that was solvedarea- the space-time domain where the solution was foundmatrix- grid values of the solution (same layout as above); must not be null
public record Solution<E extends Equation>(E extends Equation equation, Area area, Matrix2D matrix)
extends Record
Numerical PDE solution on a space-time domain:
equation(), area(), and
grid values matrix() (Matrix2D — rows are time layers, columns are spatial nodes).- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionarea()Returns the value of thearearecord component.final booleanIndicates whether some other object is "equal to" this one.equation()Returns the value of theequationrecord component.gUt(double t) Retrieves a spatial slice of the solution at a specified time moment.gUt(int it) Retrieves a spatial slice of the solution at a specified time layer index.gUx(double x) Retrieves a temporal slice of the solution at a specified spatial coordinate.gUx(int ix) Retrieves a temporal slice of the solution at a specified spatial column index.final inthashCode()Returns a hash code value for this object.matrix()Returns the value of thematrixrecord component.voidSaves solution data U(x) for a single time moment to a file.voidSaves solution data U(x,t) for specified time moments to a file.voidSaves solution data U(t) for a single spatial coordinate to a file.voidSaves solution data U(x,t) for specified spatial coordinates to a file.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
Solution
Validates record components before the instance is created.- Throws:
IllegalArgumentException- if equation, area or matrix is null
-
-
Method Details
-
sUt
Saves solution data U(x,t) for specified time moments to a file. Creates a set of spatial slices of the solution at different time points. The file starts with#-comment lines describing columns, then numeric rows in US locale (FileUtil.formatDouble(double)). Each data line contains spatial coordinates followed by solution values at different time moments. All spatial columns ofmatrix()are written (same extent asgUt(int)for a fixed time layer).Each
tis mapped to a time-layer index viaArea.ti(double)(seeInterval.i(double)): values are read from the nearest grid time level at or to the left oft, with no interpolation.- Parameters:
fileName- name of the file to save the datat- array of time moments to save- Throws:
IllegalArgumentException- if t is null, fileName is null, or any time is outside the solution domainIOException- if an I/O error occurs writing the file
-
sUt
Saves solution data U(x) for a single time moment to a file. Creates a spatial slice of the solution at the specified time. Time is resolved on the grid likesUt(String, double[])(viaArea.ti(double)).- Parameters:
fileName- name of the file to save the datat- time moment to save- Throws:
IllegalArgumentException- if fileName is null or the time moment is outside the solution domainIOException- if an I/O error occurs writing the file
-
sUx
Saves solution data U(x,t) for specified spatial coordinates to a file. Creates a set of temporal slices of the solution at different spatial points. The file starts with#-comment lines describing columns, then numeric rows in US locale (FileUtil.formatDouble(double)). Each data line contains time coordinates followed by solution values at different spatial points. All time rows ofmatrix()are written (same extent asgUx(int)for a fixed spatial column).Each
xis mapped to a spatial column index viaArea.xi(double)(seeInterval.i(double)): values are read from the nearest grid point at or to the left ofx, with no interpolation.- Parameters:
fileName- name of the file to save the datax- array of spatial coordinates to save- Throws:
IllegalArgumentException- if x is null, fileName is null, or any coordinate is outside the solution domainIOException- if an I/O error occurs writing the file
-
sUx
Saves solution data U(t) for a single spatial coordinate to a file. Creates a temporal slice of the solution at the specified spatial point. Position is resolved on the grid likesUx(String, double[])(viaArea.xi(double)).- Parameters:
fileName- name of the file to save the datax- spatial coordinate to save- Throws:
IllegalArgumentException- if fileName is null or the spatial coordinate is outside the solution domainIOException- if an I/O error occurs writing the file
-
gUt
Retrieves a spatial slice of the solution at a specified time moment. Returns a matrix containing spatial coordinates and corresponding solution values. UsesArea.ti(double)to pick the time layer (nearest grid time at or to the left oft), no interpolation.- Parameters:
t- time moment to get the slice for- Returns:
- MatrixXY containing the spatial slice of the solution
- Throws:
IllegalArgumentException- if the time moment is outside the solution domain
-
gUt
Retrieves a spatial slice of the solution at a specified time layer index. Returns a matrix containing spatial coordinates and corresponding solution values.- Parameters:
it- row index inmatrix()(time layer; 0 <= it <matrix.getM())- Returns:
- MatrixXY containing the spatial slice of the solution
- Throws:
IllegalArgumentException- if the time layer index is out of bounds
-
gUx
Retrieves a temporal slice of the solution at a specified spatial coordinate. Returns a matrix containing time coordinates and corresponding solution values. UsesArea.xi(double)to pick the spatial column (nearest grid point at or to the left ofx), no interpolation.- Parameters:
x- spatial coordinate to get the slice for- Returns:
- MatrixXY containing the temporal slice of the solution
- Throws:
IllegalArgumentException- if the spatial coordinate is outside the solution domain
-
gUx
Retrieves a temporal slice of the solution at a specified spatial column index. Returns a matrix containing time coordinates and corresponding solution values.- Parameters:
ix- column index inmatrix()(spatial node; 0 <= ix <matrix.getN())- Returns:
- MatrixXY containing the temporal slice of the solution
- Throws:
IllegalArgumentException- if the spatial column index is out of bounds
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
equation
Returns the value of theequationrecord component.- Returns:
- the value of the
equationrecord component
-
area
Returns the value of thearearecord component.- Returns:
- the value of the
arearecord component
-
matrix
Returns the value of thematrixrecord component.- Returns:
- the value of the
matrixrecord component
-