diff --git a/src/finiteVolume/fields/fvPatchFields/derived/repetitivePulseFixedValue/repetitivePulseFixedValueFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/repetitivePulseFixedValue/repetitivePulseFixedValueFvPatchField.C index 5a19c438..a26d2594 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/repetitivePulseFixedValue/repetitivePulseFixedValueFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/repetitivePulseFixedValue/repetitivePulseFixedValueFvPatchField.C @@ -38,9 +38,16 @@ scalar repetitivePulseFixedValueFvPatchField::currentScale() const { const scalar t = this->db().time().timeOutputValue(); const scalar a = amplitude_->value(t); - const scalar f = frequency_->value(t); + // const scalar f = frequency_->value(t); + const scalar f = pulseFrequency_; + const scalar tau = pulseDuration_; - return 1.0 + a*sin(constant::mathematical::twoPi*f*t); + const scalar neg_saw_t = (t - ceil(t*f)/f); + const scalar phi = neg_saw_t * constant::mathematical::pi / (2.0*tau) ; + const scalar sine = neg_saw_t > -2.0 * tau ? sin(phi) : 0.0; + + // return 1.0 + a*sin(constant::mathematical::twoPi*f*t); + return a*sine*sine; } @@ -54,10 +61,11 @@ repetitivePulseFixedValueFvPatchField::repetitivePulseFixedValueFvPatchFie ) : fixedValueFvPatchField(p, iF), - refValue_(p.size()), + peakValue_(p.size()), offset_(pTraits::zero), amplitude_(), - frequency_(), + pulseFrequency_(), + pulseDuration_(), curTimeIndex_(-1) {} @@ -72,10 +80,11 @@ repetitivePulseFixedValueFvPatchField::repetitivePulseFixedValueFvPatchFie ) : fixedValueFvPatchField(ptf, p, iF, mapper), - refValue_(ptf.refValue_, mapper), + peakValue_(ptf.peakValue_, mapper), offset_(ptf.offset_), amplitude_(ptf.amplitude_().clone().ptr()), - frequency_(ptf.frequency_().clone().ptr()), + pulseFrequency_(ptf.pulseFrequency_), + pulseDuration_(ptf.pulseDuration_), curTimeIndex_(-1) {} @@ -89,10 +98,11 @@ repetitivePulseFixedValueFvPatchField::repetitivePulseFixedValueFvPatchFie ) : fixedValueFvPatchField(p, iF), - refValue_("refValue", dict, p.size()), + peakValue_("peakValue", dict, p.size()), offset_(dict.lookupOrDefault("offset", pTraits::zero)), amplitude_(DataEntry::New("amplitude", dict)), - frequency_(DataEntry::New("frequency", dict)), + pulseFrequency_(pTraits(dict.lookup("pulseFrequency"))), + pulseDuration_(pTraits(dict.lookup("pulseDuration"))), curTimeIndex_(-1) { if (dict.found("value")) @@ -106,7 +116,7 @@ repetitivePulseFixedValueFvPatchField::repetitivePulseFixedValueFvPatchFie { fixedValueFvPatchField::operator== ( - refValue_*currentScale() + peakValue_*currentScale() + offset_ ); } @@ -120,10 +130,11 @@ repetitivePulseFixedValueFvPatchField::repetitivePulseFixedValueFvPatchFie ) : fixedValueFvPatchField(ptf), - refValue_(ptf.refValue_), + peakValue_(ptf.peakValue_), offset_(ptf.offset_), amplitude_(ptf.amplitude_().clone().ptr()), - frequency_(ptf.frequency_().clone().ptr()), + pulseFrequency_(ptf.pulseFrequency_), + pulseDuration_(ptf.pulseDuration_), curTimeIndex_(-1) {} @@ -136,10 +147,11 @@ repetitivePulseFixedValueFvPatchField::repetitivePulseFixedValueFvPatchFie ) : fixedValueFvPatchField(ptf, iF), - refValue_(ptf.refValue_), + peakValue_(ptf.peakValue_), offset_(ptf.offset_), amplitude_(ptf.amplitude_().clone().ptr()), - frequency_(ptf.frequency_().clone().ptr()), + pulseFrequency_(ptf.pulseFrequency_), + pulseDuration_(ptf.pulseDuration_), curTimeIndex_(-1) {} @@ -153,7 +165,7 @@ void repetitivePulseFixedValueFvPatchField::autoMap ) { fixedValueFvPatchField::autoMap(m); - refValue_.autoMap(m); + peakValue_.autoMap(m); } @@ -169,7 +181,7 @@ void repetitivePulseFixedValueFvPatchField::rmap const repetitivePulseFixedValueFvPatchField& tiptf = refCast >(ptf); - refValue_.rmap(tiptf.refValue_, addr); + peakValue_.rmap(tiptf.peakValue_, addr); } @@ -185,7 +197,7 @@ void repetitivePulseFixedValueFvPatchField::updateCoeffs() { fixedValueFvPatchField::operator== ( - refValue_*currentScale() + peakValue_*currentScale() + offset_ ); @@ -200,10 +212,11 @@ template void repetitivePulseFixedValueFvPatchField::write(Ostream& os) const { fixedValueFvPatchField::write(os); - refValue_.writeEntry("refValue", os); + peakValue_.writeEntry("peakValue", os); os.writeKeyword("offset") << offset_ << token::END_STATEMENT << nl; amplitude_->writeData(os); - frequency_->writeData(os); + os.writeKeyword("pulseFrequency") << pulseFrequency_ << token::END_STATEMENT << nl; + os.writeKeyword("pulseDuration") << pulseDuration_ << token::END_STATEMENT << nl; } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/repetitivePulseFixedValue/repetitivePulseFixedValueFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/derived/repetitivePulseFixedValue/repetitivePulseFixedValueFvPatchField.H index cec3e5f0..234cc99d 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/repetitivePulseFixedValue/repetitivePulseFixedValueFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/repetitivePulseFixedValue/repetitivePulseFixedValueFvPatchField.H @@ -105,7 +105,7 @@ class repetitivePulseFixedValueFvPatchField // Private data //- Reference value - Field refValue_; + Field peakValue_; //- Offset Type offset_; @@ -113,8 +113,11 @@ class repetitivePulseFixedValueFvPatchField //- Amplitude autoPtr > amplitude_; - //- Frequency - autoPtr > frequency_; + //- Pulse Frequency + scalar pulseFrequency_; + + //- Pulse Duration + scalar pulseDuration_; //- Current time index label curTimeIndex_; @@ -199,15 +202,15 @@ public: // Access //- Return the ref value - const Field& refValue() const + const Field& peakValue() const { - return refValue_; + return peakValue_; } //- Return reference to the ref value to allow adjustment - Field& refValue() + Field& peakValue() { - return refValue_; + return peakValue_; } //- Return amplitude @@ -221,15 +224,26 @@ public: return amplitude_; } - //- Return frequency - scalar frequency() const + //- Return pulse frequency + scalar pulseFrequency() const { - return frequency_; + return pulseFrequency_; } - scalar& frequency() + scalar& pulseFrequency() { - return frequency_; + return pulseFrequency_; + } + + //- Return pulse duration + scalar pulseDuration() const + { + return pulseDuration_; + } + + scalar& pulseDuration() + { + return pulseDuration_; }