JaRMoS  1.1
Java Reduced Model Simulations
 All Classes Namespaces Files Functions Variables Enumerator Groups Pages
ComplexSolutionField.java
Go to the documentation of this file.
1 package jarmos;
2 
5 
6 import org.apache.commons.math.complex.Complex;
7 
15 
16  private float[] real;
17  private float[] imaginary;
18  private float[] norms;
19  private float rmin, rmax, imin, imax;
20 
21  public int getSize() {
22  return real.length;
23  }
24 
25  public boolean isConstant() {
26  return Math.abs(rmin - rmax) < 1e-8 && Math.abs(imin - imax) < 1e-8;
27  }
28 
29  public ComplexSolutionField(FieldDescriptor f, int size) {
30  super(f);
31  real = new float[size];
32  rmin = Float.MAX_VALUE;
33  rmax = Float.MIN_VALUE;
34  imin = rmin;
35  imax = rmax;
36  }
37 
38  public void setComplexValue(int index, Complex value) {
39  setComplexValue(index, (float) value.getReal(), (float) value.getImaginary());
40  }
41 
42  public void addComplexValue(int index, Complex value) {
43  setComplexValue(index, real[index] + (float) value.getReal(), imaginary[index] + (float) value.getImaginary());
44  }
45 
46  public void addComplexValue(int index, float r, float i) {
47  setComplexValue(index, real[index] + r, imaginary[index] + i);
48  }
49 
50  public void setComplexValue(int index, float r, float i) {
51  if (imaginary == null) {
52  imaginary = new float[real.length];
53  norms = new float[real.length];
54  }
55  if (rmin > r)
56  rmin = r;
57  if (rmax < r)
58  rmax = r;
59  real[index] = r;
60  if (imin > i)
61  imin = i;
62  if (imax < i)
63  imax = i;
64  imaginary[index] = i;
65  norms[index] = (float) Math.sqrt(r * r + i * i);
66  }
67 
73  public float[][] getComplexValues() {
74  return new float[][] { real, imaginary };
75  }
76 
77  public float[] getRealDoFs() {
78  return real;
79  }
80 
81  public float[] getImaginaryDoFs() {
82  return imaginary;
83  }
84 
92  public float[] getNorms() {
93  return norms;
94  }
95 
96  public float getMaxRe() {
97  return rmax;
98  }
99 
100  public float getMinRe() {
101  return rmin;
102  }
103 
104  public float getMaxIm() {
105  return imax;
106  }
107 
108  public float getMinIm() {
109  return imin;
110  }
111 
112  @Override
114  return new VisualFeature[] { new VisualFeature(descriptor.Name + " (norms)", cg.computeColors(norms), this),
115  new VisualFeature(descriptor.Name + " (real)", cg.computeColors(real), this),
116  new VisualFeature(descriptor.Name + " (imag)", cg.computeColors(imaginary), this) };
117  }
118 }
boolean isConstant()
Convenience method to determine if the solution field is constant in value.
void setComplexValue(int index, Complex value)
float[][] getComplexValues()
Returns an two times field size-dimensional float array.
void setComplexValue(int index, float r, float i)
ComplexSolutionField(FieldDescriptor f, int size)
Represents a logical solution field of a simulation.
float[] getNorms()
Returns the norms of each entry.
void addComplexValue(int index, Complex value)
void addComplexValue(int index, float r, float i)
Simple class for feature that can be visualized.
float[] computeColors(float[] fieldValues)
Computes a 4-tuple color array with values R, G, B, Alpha for the given field values.
VisualFeature[] getVisualFeatures(ColorGenerator cg)
Abstract method that returns all available visual features for a logical solution field...
A solution field with complex values.
The color generator is used to produce RGBA (RGB+Alpha) values from a given array of floats...
Contains information about the logical solution fields.
int getSize()
Returns the number of graphical elements (nodes/vertices or elements/faces) that this field contains ...