Record Class Solution<E extends Equation>

java.lang.Object
java.lang.Record
by.andd3dfx.math.pde.solver.Solution<E>
Type Parameters:
E - the type of equation that was solved
Record Components:
equation - the partial differential equation that was solved
area - the space-time domain where the solution was found
solution - the numerical solution stored as a 2D matrix

public record Solution<E extends Equation>(E extends Equation equation, Area area, Matrix2D solution) extends Record
Record class representing a numerical solution of a partial differential equation on a defined space-time domain. The solution is stored as a 2D matrix where rows represent time layers and columns represent spatial points.
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Solution(E equation, Area area, Matrix2D solution)
    Creates an instance of a Solution record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the value of the area record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    Returns the value of the equation record 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 int
    Returns a hash code value for this object.
    Returns the value of the solution record component.
    void
    sUt(String fileName, double t)
    Saves solution data U(x) for a single time moment to a file.
    void
    sUt(String fileName, double[] t)
    Saves solution data U(x,t) for specified time moments to a file.
    void
    sUx(String fileName, double x)
    Saves solution data U(t) for a single spatial coordinate to a file.
    void
    sUx(String fileName, double[] x)
    Saves solution data U(x,t) for specified spatial coordinates to a file.
    final String
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Solution

      public Solution(E equation, Area area, Matrix2D solution)
      Creates an instance of a Solution record class.
      Parameters:
      equation - the value for the equation record component
      area - the value for the area record component
      solution - the value for the solution record component
  • Method Details

    • sUt

      public void sUt(String fileName, double[] t)
      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. Each line in the output file contains spatial coordinates followed by solution values at different time moments.
      Parameters:
      fileName - name of the file to save the data
      t - array of time moments to save
      Throws:
      IllegalArgumentException - if any time moment is outside the solution domain
    • sUt

      public void sUt(String fileName, double t)
      Saves solution data U(x) for a single time moment to a file. Creates a spatial slice of the solution at the specified time.
      Parameters:
      fileName - name of the file to save the data
      t - time moment to save
      Throws:
      IllegalArgumentException - if the time moment is outside the solution domain
    • sUx

      public void sUx(String fileName, double[] x)
      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. Each line in the output file contains time coordinates followed by solution values at different spatial points.
      Parameters:
      fileName - name of the file to save the data
      x - array of spatial coordinates to save
      Throws:
      IllegalArgumentException - if any spatial coordinate is outside the solution domain
    • sUx

      public void sUx(String fileName, double x)
      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.
      Parameters:
      fileName - name of the file to save the data
      x - spatial coordinate to save
      Throws:
      IllegalArgumentException - if the spatial coordinate is outside the solution domain
    • gUt

      public MatrixXY gUt(double t)
      Retrieves a spatial slice of the solution at a specified time moment. Returns a matrix containing spatial coordinates and corresponding solution values.
      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

      public MatrixXY gUt(int it)
      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 - index of the time layer in the solution matrix (0 <= it < M)
      Returns:
      MatrixXY containing the spatial slice of the solution
      Throws:
      IllegalArgumentException - if the time layer index is out of bounds
    • gUx

      public MatrixXY gUx(double x)
      Retrieves a temporal slice of the solution at a specified spatial coordinate. Returns a matrix containing time coordinates and corresponding solution values.
      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

      public MatrixXY gUx(int ix)
      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 - index of the spatial column in the solution matrix (0 <= ix < N)
      Returns:
      MatrixXY containing the temporal slice of the solution
      Throws:
      IllegalArgumentException - if the spatial column index is out of bounds
    • toString

      public final String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • equation

      public E equation()
      Returns the value of the equation record component.
      Returns:
      the value of the equation record component
    • area

      public Area area()
      Returns the value of the area record component.
      Returns:
      the value of the area record component
    • solution

      public Matrix2D solution()
      Returns the value of the solution record component.
      Returns:
      the value of the solution record component