Commit 7b23d776 authored by rink's avatar rink
Browse files

set time step based on method

parent f4f85501
......@@ -377,6 +377,9 @@ public class TrajectoryManager {
}
float timeStep = (float) timeSteps[i]/numIntrpPts;
if (!trajDoIntrp && (method == TrajectoryParams.Method.RK4)) {
timeStep *= 2;
}
if ((timeAccum >= trajRefreshInterval)) { // for non steady state trajectories (refresh frequency)
trajectories = new ArrayList<Trajectory>();
......@@ -439,7 +442,7 @@ public class TrajectoryManager {
int numTrajectories = trajectories.size();
reset();
for (int ti=0; ti<numIntrpPts; ti++) { // additional points per domain time step
double dst = (x1 - x0)/numIntrpPts;
double xt = x0 + dst*ti;
......@@ -450,54 +453,37 @@ public class TrajectoryManager {
vInterp.interpolate(xt, intrpV);
wInterp.interpolate(xt, intrpW);
if (method == TrajectoryParams.Method.RK4) {
if ((ti == numIntrpPts-1) && (k == dataDomainLength-2)) {
System.arraycopy(values1[0], 0, intrpU_1, 0, intrpU_1.length);
System.arraycopy(values1[1], 0, intrpV_1, 0, intrpV_1.length);
System.arraycopy(values1[2], 0, intrpW_1, 0, intrpW_1.length);
intrpU = mean(intrpU, intrpU_1);
intrpV = mean(intrpV, intrpV_1);
intrpW = mean(intrpW, intrpW_1);
for (int t=0; t<numTrajectories; t++) {
Trajectory traj = trajectories.get(t);
traj.currentTimeIndex = direction*i;
traj.currentTime = direction*times[i];
traj.forward(info, new float[][] {intrpU, intrpV, intrpW}, color_values, spatialSetTraj, terrain, direction, timeStep);
if (method == TrajectoryParams.Method.RK4) { // Runge-Kutta
double step = dst;
if (!trajDoIntrp) {
step = 2*dst;
}
}
else {
uInterp.interpolate(xt+dst, intrpU_1);
vInterp.interpolate(xt+dst, intrpV_1);
wInterp.interpolate(xt+dst, intrpW_1);
if (k == dataDomainLength-2 && ti > numIntrpPts-2) {
continue;
}
uInterp.interpolate(xt+step/2, intrpU_1);
vInterp.interpolate(xt+step/2, intrpV_1);
wInterp.interpolate(xt+step/2, intrpW_1);
uInterp.interpolate(xt+2*dst, intrpU_2);
vInterp.interpolate(xt+2*dst, intrpV_2);
wInterp.interpolate(xt+2*dst, intrpW_2);
uInterp.interpolate(xt+step, intrpU_2);
vInterp.interpolate(xt+step, intrpV_2);
wInterp.interpolate(xt+step, intrpW_2);
for (int t=0; t<numTrajectories; t++) {
Trajectory traj = trajectories.get(t);
traj.currentTimeIndex = direction*i;
traj.currentTime = direction*times[i];
traj.forwardRK4(info, new float[][] {intrpU, intrpV, intrpW},
new float[][] {intrpU_1, intrpV_1, intrpW_1},
new float[][] {intrpU_2, intrpV_2, intrpW_2},
color_values, spatialSetTraj, terrain, direction, timeStep);
new float[][] {intrpU_1, intrpV_1, intrpW_1},
new float[][] {intrpU_2, intrpV_2, intrpW_2},
color_values, spatialSetTraj, terrain, direction, timeStep);
}
}
}
else {
if (method == TrajectoryParams.Method.HySplit) { // NOAA HySplit
if (ti == numIntrpPts-1) {
System.arraycopy(values1[0], 0, intrpU_1, 0, intrpU_1.length);
System.arraycopy(values1[1], 0, intrpV_1, 0, intrpV_1.length);
System.arraycopy(values1[2], 0, intrpW_1, 0, intrpW_1.length);
}
else {
uInterp.interpolate(xt+dst, intrpU_1);
vInterp.interpolate(xt+dst, intrpV_1);
wInterp.interpolate(xt+dst, intrpW_1);
}
uInterp.interpolate(xt+dst, intrpU_1);
vInterp.interpolate(xt+dst, intrpV_1);
wInterp.interpolate(xt+dst, intrpW_1);
intrpU = mean(intrpU, intrpU_1);
intrpV = mean(intrpV, intrpV_1);
......@@ -2380,43 +2366,49 @@ public class TrajectoryManager {
String propStr = null;
propStr = prop.getProperty("CylinderWidthFactor");
if (propStr != null) {
float fac = Float.valueOf(propStr);
float fac = Float.valueOf(propStr.trim());
trajParams.setCylinderWidth(trajParams.getCylinderWidth()*fac);
}
propStr = prop.getProperty("RibbonWidthFactor");
if (propStr != null) {
float fac = Float.valueOf(propStr);
float fac = Float.valueOf(propStr.trim());
trajParams.setRibbonWidthFactor(fac);
}
propStr = prop.getProperty("ManualIntrpPts");
if (propStr != null) {
trajParams.setManualIntrpPts(Boolean.valueOf(propStr));
trajParams.setManualIntrpPts(Boolean.valueOf(propStr.trim()));
}
propStr = prop.getProperty("TrajDoIntrp");
if (propStr != null) {
trajParams.setDoIntrp(Boolean.valueOf(propStr));
trajParams.setDoIntrp(Boolean.valueOf(propStr.trim()));
}
propStr = prop.getProperty("TerrainFollow");
if (propStr != null) {
trajParams.setTerrainFollowing(Boolean.valueOf(propStr));
trajParams.setTerrainFollowing(Boolean.valueOf(propStr.trim()));
}
propStr = prop.getProperty("NumIntrpPts");
if (propStr != null) {
trajParams.setNumIntrpPts(Integer.valueOf(propStr));
trajParams.setNumIntrpPts(Integer.valueOf(propStr.trim()));
}
propStr = prop.getProperty("TrajRefreshInterval");
if (propStr != null) {
trajParams.setTrajRefreshInterval(Double.valueOf(propStr));
trajParams.setTrajRefreshInterval(Double.valueOf(propStr.trim()));
}
propStr = prop.getProperty("StartSkip");
if (propStr != null) {
trajParams.setStartSkip(Integer.valueOf(propStr.trim()));
}
propStr = prop.getProperty("TrajForm");
if (propStr != null) {
propStr = propStr.trim();
if (propStr.equals("LINE")) {
trajParams.setTrajectoryForm(TrajectoryParams.LINE);
}
......@@ -2436,6 +2428,7 @@ public class TrajectoryManager {
propStr = prop.getProperty("Method");
if (propStr != null) {
propStr = propStr.trim();
if (propStr.equals("HYSPLIT")) {
trajParams.setMethod(TrajectoryParams.Method.HySplit);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment