repetitivePulseFixedValue is implemented
This commit is contained in:
parent
f1676f8685
commit
ae96c4804a
2 changed files with 57 additions and 30 deletions
|
|
@ -38,9 +38,16 @@ scalar repetitivePulseFixedValueFvPatchField<Type>::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<Type>::repetitivePulseFixedValueFvPatchFie
|
|||
)
|
||||
:
|
||||
fixedValueFvPatchField<Type>(p, iF),
|
||||
refValue_(p.size()),
|
||||
peakValue_(p.size()),
|
||||
offset_(pTraits<Type>::zero),
|
||||
amplitude_(),
|
||||
frequency_(),
|
||||
pulseFrequency_(),
|
||||
pulseDuration_(),
|
||||
curTimeIndex_(-1)
|
||||
{}
|
||||
|
||||
|
|
@ -72,10 +80,11 @@ repetitivePulseFixedValueFvPatchField<Type>::repetitivePulseFixedValueFvPatchFie
|
|||
)
|
||||
:
|
||||
fixedValueFvPatchField<Type>(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<Type>::repetitivePulseFixedValueFvPatchFie
|
|||
)
|
||||
:
|
||||
fixedValueFvPatchField<Type>(p, iF),
|
||||
refValue_("refValue", dict, p.size()),
|
||||
peakValue_("peakValue", dict, p.size()),
|
||||
offset_(dict.lookupOrDefault<Type>("offset", pTraits<Type>::zero)),
|
||||
amplitude_(DataEntry<scalar>::New("amplitude", dict)),
|
||||
frequency_(DataEntry<scalar>::New("frequency", dict)),
|
||||
pulseFrequency_(pTraits<scalar>(dict.lookup("pulseFrequency"))),
|
||||
pulseDuration_(pTraits<scalar>(dict.lookup("pulseDuration"))),
|
||||
curTimeIndex_(-1)
|
||||
{
|
||||
if (dict.found("value"))
|
||||
|
|
@ -106,7 +116,7 @@ repetitivePulseFixedValueFvPatchField<Type>::repetitivePulseFixedValueFvPatchFie
|
|||
{
|
||||
fixedValueFvPatchField<Type>::operator==
|
||||
(
|
||||
refValue_*currentScale()
|
||||
peakValue_*currentScale()
|
||||
+ offset_
|
||||
);
|
||||
}
|
||||
|
|
@ -120,10 +130,11 @@ repetitivePulseFixedValueFvPatchField<Type>::repetitivePulseFixedValueFvPatchFie
|
|||
)
|
||||
:
|
||||
fixedValueFvPatchField<Type>(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<Type>::repetitivePulseFixedValueFvPatchFie
|
|||
)
|
||||
:
|
||||
fixedValueFvPatchField<Type>(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<Type>::autoMap
|
|||
)
|
||||
{
|
||||
fixedValueFvPatchField<Type>::autoMap(m);
|
||||
refValue_.autoMap(m);
|
||||
peakValue_.autoMap(m);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -169,7 +181,7 @@ void repetitivePulseFixedValueFvPatchField<Type>::rmap
|
|||
const repetitivePulseFixedValueFvPatchField<Type>& tiptf =
|
||||
refCast<const repetitivePulseFixedValueFvPatchField<Type> >(ptf);
|
||||
|
||||
refValue_.rmap(tiptf.refValue_, addr);
|
||||
peakValue_.rmap(tiptf.peakValue_, addr);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -185,7 +197,7 @@ void repetitivePulseFixedValueFvPatchField<Type>::updateCoeffs()
|
|||
{
|
||||
fixedValueFvPatchField<Type>::operator==
|
||||
(
|
||||
refValue_*currentScale()
|
||||
peakValue_*currentScale()
|
||||
+ offset_
|
||||
);
|
||||
|
||||
|
|
@ -200,10 +212,11 @@ template<class Type>
|
|||
void repetitivePulseFixedValueFvPatchField<Type>::write(Ostream& os) const
|
||||
{
|
||||
fixedValueFvPatchField<Type>::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;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ class repetitivePulseFixedValueFvPatchField
|
|||
// Private data
|
||||
|
||||
//- Reference value
|
||||
Field<Type> refValue_;
|
||||
Field<Type> peakValue_;
|
||||
|
||||
//- Offset
|
||||
Type offset_;
|
||||
|
|
@ -113,8 +113,11 @@ class repetitivePulseFixedValueFvPatchField
|
|||
//- Amplitude
|
||||
autoPtr<DataEntry<scalar> > amplitude_;
|
||||
|
||||
//- Frequency
|
||||
autoPtr<DataEntry<scalar> > 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<Type>& refValue() const
|
||||
const Field<Type>& peakValue() const
|
||||
{
|
||||
return refValue_;
|
||||
return peakValue_;
|
||||
}
|
||||
|
||||
//- Return reference to the ref value to allow adjustment
|
||||
Field<Type>& refValue()
|
||||
Field<Type>& 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_;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue