WorldPoint3D ADCPMover_c::GetMove(const Seconds& model_time, Seconds timeStep,long setIndex,long leIndex,LERec *theLE,LETYPE leType) { Boolean useEddyUncertainty = false; double dLong, dLat; WorldPoint3D deltaPoint={0,0,0.}; WorldPoint refPoint = (*theLE).p; WorldPoint3D thisPoint; VelocityRec scaledPatVelocity = {0.,0.}; thisPoint.p = (*theLE).p; thisPoint.z = (*theLE).z; scaledPatVelocity = this->GetVelocityAtPoint(thisPoint); if(leType == UNCERTAINTY_LE) { AddUncertainty(setIndex,leIndex,&scaledPatVelocity,timeStep,useEddyUncertainty); } dLong = ((scaledPatVelocity.u / METERSPERDEGREELAT) * timeStep) / LongToLatRatio3 (refPoint.pLat); dLat = (scaledPatVelocity.v / METERSPERDEGREELAT) * timeStep; deltaPoint.p.pLong = dLong * 1000000; deltaPoint.p.pLat = dLat * 1000000; //deltaPoint.p.z = scaledPatVelocity.w * timeStep; return deltaPoint; }
WorldPoint3D GridWindMover_c::GetMove(const Seconds& model_time, Seconds timeStep,long setIndex,long leIndex,LERec *theLE,LETYPE leType) { double dLong, dLat; WorldPoint3D deltaPoint ={0,0,0.}; WorldPoint3D refPoint; double timeAlpha; long index; Seconds startTime,endTime; //Seconds time = model->GetModelTime(); VelocityRec windVelocity; OSErr err = noErr; char errmsg[256]; if ((*theLE).z > 0) return deltaPoint; // wind doesn't act below surface // or use some sort of exponential decay below the surface... if(!fIsOptimizedForStep) { err = timeGrid -> SetInterval(errmsg, model_time); // AH 07/17/2012 if (err) return deltaPoint; } refPoint.p = (*theLE).p; refPoint.z = (*theLE).z; windVelocity = timeGrid->GetScaledPatValue(model_time, refPoint); //windVelocity.u *= fWindScale; //windVelocity.v *= fWindScale; if(leType == UNCERTAINTY_LE) { err = AddUncertainty(setIndex,leIndex,&windVelocity); } windVelocity.u *= (*theLE).windage; windVelocity.v *= (*theLE).windage; dLong = ((windVelocity.u / METERSPERDEGREELAT) * timeStep) / LongToLatRatio3 (refPoint.p.pLat); dLat = (windVelocity.v / METERSPERDEGREELAT) * timeStep; deltaPoint.p.pLong = dLong * 1000000; deltaPoint.p.pLat = dLat * 1000000; return deltaPoint; }
WorldPoint3D ComponentMover_c::GetMove (const Seconds& model_time, Seconds timeStep,long setIndex,long leIndex,LERec *theLE,LETYPE leType) { double dLat, dLong; WorldPoint3D deltaPoint = {0,0,0.}; WorldPoint refPoint = (*theLE).p; WorldPoint3D refPoint3D = {0,0,0.}; VelocityRec finalVel, pat1Val,pat2Val; OSErr err = 0; char errmsg[256]; refPoint3D.p = refPoint; pat1Val = pattern1 -> GetPatValue (refPoint3D); if (pattern2) pat2Val = pattern2 -> GetPatValue (refPoint3D); else { pat2Val.u = pat2Val.v = 0; } if (!fOptimize.isOptimizedForStep) { err = SetOptimizeVariables (errmsg, model_time, timeStep); if (err) return deltaPoint; } finalVel.u = pat1Val.u * fOptimize.pat1ValScale + pat2Val.u * fOptimize.pat2ValScale; finalVel.v = pat1Val.v * fOptimize.pat1ValScale + pat2Val.v * fOptimize.pat2ValScale; if(leType == UNCERTAINTY_LE) { AddUncertainty(setIndex,leIndex,&finalVel,timeStep); } dLong = ((finalVel.u / METERSPERDEGREELAT) * timeStep) / LongToLatRatio3 (refPoint.pLat); dLat = (finalVel.v / METERSPERDEGREELAT) * timeStep; deltaPoint.p.pLong = dLong * 1000000; deltaPoint.p.pLat = dLat * 1000000; return deltaPoint; }
WorldPoint3D GridWndMover_c::GetMove(const Seconds& model_time, Seconds timeStep,long setIndex,long leIndex,LERec *theLE,LETYPE leType) { double dLong, dLat; WorldPoint3D deltaPoint ={0,0,0.}; WorldPoint refPoint = (*theLE).p; double timeAlpha; long index; Seconds startTime,endTime; Seconds time = model->GetModelTime(); VelocityRec windVelocity; OSErr err = noErr; char errmsg[256]; // if ((*theLE).z > 0) return deltaPoint; // wind doesn't act below surface // or use some sort of exponential decay below the surface... if(!fIsOptimizedForStep) { err = dynamic_cast<GridWndMover *>(this) -> SetInterval(errmsg, model_time); // AH 07/17/2012 if (err) return deltaPoint; } index = GetVelocityIndex(refPoint); // regular grid // Check for constant wind if(dynamic_cast<GridWndMover *>(this)->GetNumTimesInFile()==1) { // Calculate the interpolated velocity at the point if (index >= 0) { windVelocity.u = INDEXH(fStartData.dataHdl,index).u; windVelocity.v = INDEXH(fStartData.dataHdl,index).v; } else // set vel to zero { windVelocity.u = 0.; windVelocity.v = 0.; } } else // time varying wind { // Calculate the time weight factor if (dynamic_cast<GridWndMover *>(this)->GetNumFiles()>1 && fOverLap) startTime = fOverLapStartTime; else startTime = (*fTimeDataHdl)[fStartData.timeIndex].time; //startTime = (*fTimeDataHdl)[fStartData.timeIndex].time; endTime = (*fTimeDataHdl)[fEndData.timeIndex].time; timeAlpha = (endTime - time)/(double)(endTime - startTime); // Calculate the interpolated velocity at the point if (index >= 0) { windVelocity.u = timeAlpha*INDEXH(fStartData.dataHdl,index).u + (1-timeAlpha)*INDEXH(fEndData.dataHdl,index).u; windVelocity.v = timeAlpha*INDEXH(fStartData.dataHdl,index).v + (1-timeAlpha)*INDEXH(fEndData.dataHdl,index).v; } else // set vel to zero { windVelocity.u = 0.; windVelocity.v = 0.; } } //scale: windVelocity.u *= fWindScale; windVelocity.v *= fWindScale; if(leType == UNCERTAINTY_LE) { err = AddUncertainty(setIndex,leIndex,&windVelocity); } windVelocity.u *= (*theLE).windage; windVelocity.v *= (*theLE).windage; dLong = ((windVelocity.u / METERSPERDEGREELAT) * timeStep) / LongToLatRatio3 (refPoint.pLat); dLat = (windVelocity.v / METERSPERDEGREELAT) * timeStep; deltaPoint.p.pLong = dLong * 1000000; deltaPoint.p.pLat = dLat * 1000000; return deltaPoint; }
WorldPoint3D NetCDFWindMoverCurv_c::GetMove(const Seconds& model_time, Seconds timeStep,long setIndex,long leIndex,LERec *theLE,LETYPE leType) { WorldPoint3D deltaPoint = {0,0,0.}; WorldPoint refPoint = (*theLE).p; double dLong, dLat; double timeAlpha; long index = -1; Seconds startTime,endTime; Seconds time = model->GetModelTime(); VelocityRec windVelocity; OSErr err = 0; char errmsg[256]; if ((*theLE).z > 0) return deltaPoint; // wind doesn't act below surface if(!fIsOptimizedForStep) { err = dynamic_cast<NetCDFWindMoverCurv *>(this) -> SetInterval(errmsg, model_time); // AH 07/17/2012 if (err) return deltaPoint; } if (fGrid) // for now just use the u,v at left and bottom midpoints of grid box as velocity over entire gridbox index = ((TTriGridVel*)fGrid)->GetRectIndexFromTriIndex(refPoint,fVerdatToNetCDFH,fNumCols+1);// curvilinear grid // Check for constant wind //if(GetNumTimesInFile()==1) if(dynamic_cast<NetCDFWindMoverCurv *>(this)->GetNumTimesInFile()==1 || (fEndData.timeIndex == UNASSIGNEDINDEX && time > ((*fTimeHdl)[fStartData.timeIndex] + fTimeShift) && fAllowExtrapolationOfWinds) || (fEndData.timeIndex == UNASSIGNEDINDEX && time < ((*fTimeHdl)[fStartData.timeIndex] + fTimeShift) && fAllowExtrapolationOfWinds)) { // Calculate the interpolated velocity at the point if (index >= 0) { windVelocity.u = INDEXH(fStartData.dataHdl,index).u; windVelocity.v = INDEXH(fStartData.dataHdl,index).v; } else // set vel to zero { windVelocity.u = 0.; windVelocity.v = 0.; } } else // time varying wind { // Calculate the time weight factor startTime = (*fTimeHdl)[fStartData.timeIndex] + fTimeShift; endTime = (*fTimeHdl)[fEndData.timeIndex] + fTimeShift; timeAlpha = (endTime - time)/(double)(endTime - startTime); // Calculate the interpolated velocity at the point if (index >= 0) { windVelocity.u = timeAlpha*INDEXH(fStartData.dataHdl,index).u + (1-timeAlpha)*INDEXH(fEndData.dataHdl,index).u; windVelocity.v = timeAlpha*INDEXH(fStartData.dataHdl,index).v + (1-timeAlpha)*INDEXH(fEndData.dataHdl,index).v; } else // set vel to zero { windVelocity.u = 0.; windVelocity.v = 0.; } } scale: windVelocity.u *= fWindScale; // may want to allow some sort of scale factor, though should be in file windVelocity.v *= fWindScale; if(leType == UNCERTAINTY_LE) { err = AddUncertainty(setIndex,leIndex,&windVelocity); } windVelocity.u *= (*theLE).windage; windVelocity.v *= (*theLE).windage; dLong = ((windVelocity.u / METERSPERDEGREELAT) * timeStep) / LongToLatRatio3 (refPoint.pLat); dLat = (windVelocity.v / METERSPERDEGREELAT) * timeStep; deltaPoint.p.pLong = dLong * 1000000; deltaPoint.p.pLat = dLat * 1000000; return deltaPoint; }
WorldPoint3D TriCurMover_c::GetMove(const Seconds& model_time, Seconds timeStep,long setIndex,long leIndex,LERec *theLE,LETYPE leType) { // figure out which depth values the LE falls between // since velocities are at centers no need to interpolate, use value over whole triangle // and some sort of check on the returned indices, what to do if one is below bottom? // for sigma model might have different depth values at each point // for multilayer they should be the same, so only one interpolation would be needed // others don't have different velocities at different depths so no interpolation is needed WorldPoint3D deltaPoint = {0,0,0.}; WorldPoint refPoint = (*theLE).p; double dLong, dLat; double timeAlpha, depth = (*theLE).z; long depthIndex1, depthIndex2, velDepthIndex1, velDepthIndex2 = -1; double topDepth, bottomDepth, depthAlpha; Seconds startTime,endTime; Seconds time = model->GetModelTime(); VelocityRec scaledPatVelocity = {0.,0.}; Boolean useEddyUncertainty = false; OSErr err = 0; char errmsg[256]; long triNum, numDepths = 0, totalDepth = 0; if(!fIsOptimizedForStep) { err = dynamic_cast<TriCurMover *>(this) -> SetInterval(errmsg, model_time); // AH 07/17/2012 if (err) return deltaPoint; } triNum = WhatTriAmIIn(refPoint); if (triNum < 0) return deltaPoint; // probably an error if (fDepthDataInfo) totalDepth = INDEXH(fDepthDataInfo,triNum).totalDepth; // depth from input file (?) at triangle center if (fDepthsH) numDepths = _GetHandleSize((Handle)fDepthsH)/sizeof(fDepthsH); GetDepthIndices(triNum,depth,&depthIndex1,&depthIndex2); if (depthIndex1 == -1) return deltaPoint; if(dynamic_cast<TriCurMover *>(this)->GetNumTimesInFile()==1 /*&& !(GetNumFiles()>1)*/) { if (depthIndex1!=-1) { if (depthIndex2!=-1 && numDepths > 0 && totalDepth > 0) { topDepth = INDEXH(fDepthsH,depthIndex1); bottomDepth = INDEXH(fDepthsH,depthIndex2); depthAlpha = (bottomDepth - depth)/(double)(bottomDepth - topDepth); scaledPatVelocity.u = depthAlpha*(INDEXH(fStartData.dataHdl,depthIndex1).u) + (1-depthAlpha)*(INDEXH(fStartData.dataHdl,depthIndex2).u); scaledPatVelocity.v = depthAlpha*(INDEXH(fStartData.dataHdl,depthIndex1).v) + (1-depthAlpha)*(INDEXH(fStartData.dataHdl,depthIndex2).v); } else { scaledPatVelocity.u = INDEXH(fStartData.dataHdl,depthIndex1).u; scaledPatVelocity.v = INDEXH(fStartData.dataHdl,depthIndex1).v; } } } else // time varying current { // Calculate the time weight factor /*if (GetNumFiles()>1 && fOverLap) startTime = fOverLapStartTime; else*/ startTime = (*fTimeDataHdl)[fStartData.timeIndex].time; endTime = (*fTimeDataHdl)[fEndData.timeIndex].time; timeAlpha = (endTime - time)/(double)(endTime - startTime); if (depthIndex1!=-1) { if (depthIndex2!=-1 && numDepths > 0 && totalDepth > 0) { topDepth = INDEXH(fDepthsH,depthIndex1); bottomDepth = INDEXH(fDepthsH,depthIndex2); depthAlpha = (bottomDepth - depth)/(double)(bottomDepth - topDepth); scaledPatVelocity.u = depthAlpha*(timeAlpha*INDEXH(fStartData.dataHdl,depthIndex1).u + (1-timeAlpha)*INDEXH(fEndData.dataHdl,depthIndex1).u) + (1-depthAlpha)*(timeAlpha*INDEXH(fStartData.dataHdl,depthIndex2).u + (1-timeAlpha)*INDEXH(fEndData.dataHdl,depthIndex2).u); scaledPatVelocity.v = depthAlpha*(timeAlpha*INDEXH(fStartData.dataHdl,depthIndex1).v + (1-timeAlpha)*INDEXH(fEndData.dataHdl,depthIndex1).v) + (1-depthAlpha)*(timeAlpha*INDEXH(fStartData.dataHdl,depthIndex2).v + (1-timeAlpha)*INDEXH(fEndData.dataHdl,depthIndex2).v); } else { scaledPatVelocity.u = timeAlpha*INDEXH(fStartData.dataHdl,depthIndex1).u + (1-timeAlpha)*INDEXH(fEndData.dataHdl,depthIndex1).u; scaledPatVelocity.v = timeAlpha*INDEXH(fStartData.dataHdl,depthIndex1).v + (1-timeAlpha)*INDEXH(fEndData.dataHdl,depthIndex1).v; } } } scaledPatVelocity.u *= fVar.curScale; scaledPatVelocity.v *= fVar.curScale; if(leType == UNCERTAINTY_LE) { AddUncertainty(setIndex,leIndex,&scaledPatVelocity,timeStep,useEddyUncertainty); } dLong = ((scaledPatVelocity.u / METERSPERDEGREELAT) * timeStep) / LongToLatRatio3 (refPoint.pLat); dLat = (scaledPatVelocity.v / METERSPERDEGREELAT) * timeStep; deltaPoint.p.pLong = dLong * 1000000; deltaPoint.p.pLat = dLat * 1000000; return deltaPoint; }