1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
|
/* $Id: ConstituentSet.hh 2641 2007-09-02 21:31:02Z flaterco $
ConstituentSet: set of constituents, datum, and related methods.
Copyright (C) 1997 David Flater.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
class ConstituentSet {
public:
// Null constituents should have been eliminated in HarmonicsFile.
// On construction, constituents and datum are (permanently)
// adjusted according to adjustments.
ConstituentSet (const SafeVector<Constituent> &constituents,
PredictionValue datum,
const SimpleOffsets &adjustments);
// Change preferred units of length.
// Default is as specified by settings.
// Attempts to set same units are tolerated without complaint.
// Attempts to set velocity units are punished.
void setUnits (Units::PredictionUnits units);
// Tell me what units tideDerivative will return.
const Units::PredictionUnits predictUnits () const;
// These will never have a value of type KnotsSquared.
const Amplitude maxAmplitude() const;
const PredictionValue datum() const;
// Calculate (deriv)th time derivative of the normalized tide (for
// time in s). The result does not have the datum added in and will
// not be converted from KnotsSquared.
const PredictionValue tideDerivative (Timestamp predictTime, unsigned deriv);
#ifdef blendingTest
// For testing only.
void tideDerivativeBlendValues (Timestamp predictTime,
unsigned deriv,
NullablePredictionValue &firstYear_out,
NullablePredictionValue &secondYear_out);
#endif
// Return the maximum that the absolute value of the (deriv)th
// derivative of the tide can ever attain, plus "a little safety
// margin." tideDerivativeMax(0) == maxAmplitude() * 1.1
const Amplitude tideDerivativeMax (unsigned deriv) const;
protected:
SafeVector<Constituent> _constituents;
const unsigned length; // = _constituents.size()
PredictionValue _datum;
// The following are what get accessed directly in tideDerivative.
// Amplitudes are constituent amplitudes times node factors.
// Phases are constituent phases plus equilibrium arguments.
// Optimization: Conversion of amplitudes to PredictionValue is
// done in advance instead of on every reference inside of
// tideDerivative. The conversion from Amplitude to PredictionValue
// could not be inlined because of a circular dependency.
SafeVector<PredictionValue> amplitudes;
SafeVector<Angle> phases;
// Maximum derivative supported by tideDerivative and family.
static const unsigned maxDeriv = 2U;
Amplitude _maxAmplitude;
Amplitude maxdt[maxDeriv+2];
Year currentYear;
Timestamp epoch;
Timestamp nextEpoch;
Units::PredictionUnits preferredLengthUnits;
// Update amplitudes, phases, epoch, nextEpoch, and currentYear.
void changeYear (Year newYear);
// Calculate (deriv)th time derivative of the normalized tide for
// time in s since the beginning (UTC) of currentYear, WITHOUT
// changing years or blending.
const PredictionValue tideDerivative (Interval sinceEpoch, unsigned deriv);
// Called by tideDerivative(Timestamp) to blend tides near year ends.
const PredictionValue blendTide (Timestamp predictTime,
unsigned deriv,
Year firstYear,
double blend);
};
// Cleanup2006 Done
|