JaRMoS  1.1
Java Reduced Model Simulations
 All Classes Namespaces Files Functions Variables Enumerator Groups Pages
DefaultSolutionField.java
Go to the documentation of this file.
1 package jarmos;
2 
6 
15 
16  public static LogicSolutionField getZeroField(int size, FieldMapping mapping) {
18  f.Name = "All-Zero real field";
19  f.Mapping = mapping;
20  return new DefaultSolutionField(f, size);
21  }
22 
23  private float[] values;
24 
25  public int getSize() {
26  return values.length;
27  }
28 
29  private float min, max;
30 
31  public DefaultSolutionField(FieldDescriptor f, int size) {
32  super(f);
33  values = new float[size];
34  min = Float.MAX_VALUE;
35  max = Float.MIN_VALUE;
36  }
37 
43  public DefaultSolutionField(FieldDescriptor f, float[] values) {
44  this(f, values.length);
45  for (int i = 0; i < values.length; i++) {
46  setValue(i, values[i]);
47  }
48  }
49 
50  public void setValue(int index, float value) {
51  values[index] = value;
52  if (min > value)
53  min = value;
54  if (max < value)
55  max = value;
56  }
57 
58  public float getMax() {
59  return max;
60  }
61 
62  public float getMin() {
63  return min;
64  }
65 
66  public boolean isConstant() {
67  return Math.abs(min - max) < 1e-8;
68  }
69 
70  @Override
72  String n = descriptor.Name;
73  if (n == null || n == "") {
74  n = "(no name)";
75  }
76  return new VisualFeature[] { new VisualFeature(descriptor.Name, cg.computeColors(values), this) };
77  }
78 }
Represents a logical solution field of a simulation.
void setValue(int index, float value)
The default solution field containing an array of real values.
DefaultSolutionField(FieldDescriptor f, float[] values)
Compatibility constructor.
This enum contains all so far known (to JaRMoSBase) types of logical solution fields.
int getSize()
Returns the number of graphical elements (nodes/vertices or elements/faces) that this field contains ...
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.
static LogicSolutionField getZeroField(int size, FieldMapping mapping)
VisualFeature[] getVisualFeatures(ColorGenerator cg)
Abstract method that returns all available visual features for a logical solution field...
The field mapping determines how the DoF of the solution are mapped into the given geometry...
DefaultSolutionField(FieldDescriptor f, int size)
The color generator is used to produce RGBA (RGB+Alpha) values from a given array of floats...
boolean isConstant()
Convenience method to determine if the solution field is constant in value.
Contains information about the logical solution fields.