Beispiel #1
0
cnoidalFirst::cnoidalFirst
(
    const word & subDictName,
	const fvMesh & mesh_
)
:
    waveTheory(subDictName, mesh_),
    H_(readScalar(coeffDict_.lookup("height"))),
    h_(readScalar(coeffDict_.lookup("depth"))),
    omega_(readScalar(coeffDict_.lookup("omega"))),

    propagationDirection_(vector(coeffDict_.lookup("direction"))),
    m_(readScalar(coeffDict_.lookup("m"))),
    length_(readScalar(coeffDict_.lookup("length"))),
    celerity_(readScalar(coeffDict_.lookup("celerity")))
{   
    scalar Eelliptic = gsl_sf_ellint_Ecomp( Foam::sqrt(m_), GSL_PREC_DOUBLE);

    period_    = 2.0 * PI_ / omega_;

    Kelliptic_ = gsl_sf_ellint_Kcomp( Foam::sqrt(m_), GSL_PREC_DOUBLE);
    etaMin_    = ((1.0 - Eelliptic / Kelliptic_) / m_ - 1.0) * H_;

    propagationDirection_ /= Foam::mag(propagationDirection_);
    
    Tsoft_ = coeffDict_.lookupOrDefault<scalar>("Tsoft",period_);
}
void cnoidalFirstProperties::set( Ostream& os)
{
    scalar m = solve();

    // Write the beginning of the sub-dictionary
    writeBeginning( os );

    // Write the already given parameters
    writeGiven( os, "waveType" );

    if (dict_.found( "Tsoft" ))
    {
        writeGiven( os, "Tsoft");
    }

    writeGiven( os, "depth");
    writeGiven( os, "period");
    writeGiven( os, "height");

    if (m < 0.0)
    {
        Info << "\nPARAMETERS NOT SET\nNo cnoidal wave solution"
             << " exists for given input\n" << endl;
    }
    else
    {
        double K = gsl_sf_ellint_Kcomp( Foam::sqrt(m), GSL_PREC_DOUBLE );
        double E = gsl_sf_ellint_Ecomp( Foam::sqrt(m), GSL_PREC_DOUBLE );

        double A = 2.0/m - 1.0 - 3.0/m*E/K;

        double L =
            Foam::sqrt(16.0*m * Foam::pow(K, 2.0)*Foam::pow(d_, 3.0)/(3.0*H_));
        double c = Foam::sqrt( G_*d_*(1 + A*H_/d_));
        double omega = 2*PI_/T_;

        if (write_)
        {
            writeDerived(os, "omega", omega);
            writeDerived(os, "length", L);
            writeDerived(os, "celerity", c);

            // Locally change the write precision for m to avoid it being
            // written as 1 instead of 0.9999999999 which makes elliptic
            // integrals to infinity.
            unsigned int pre = os.precision( 14 );
            writeDerived(os, "m", m);
            os.precision( pre );
        }
    }

    writeGiven( os, "direction" );

    // Write the relaxation zone
    writeRelaxationZone( os );

    // Write the closing bracket
    writeEnding( os );
}
Beispiel #3
0
double
  ell (double x)
{

  double k = x;
  gsl_mode_t mode = GSL_PREC_DOUBLE;
  double var = (gsl_sf_ellint_Kcomp(k, mode) - gsl_sf_ellint_Ecomp(k, mode));

  return var;
}
double lowerMBound_f ( double m, void *params )
{
    // Solves to find the value of m at which Foam::sqrt(1.0 + H/d*A) == 0.0
    struct cnoidalFirstParams *p = (struct cnoidalFirstParams * ) params;

    double d = p->depth_;
    double H = p->height_;

    double K = gsl_sf_ellint_Kcomp( Foam::sqrt(m), GSL_PREC_DOUBLE );
    double E = gsl_sf_ellint_Ecomp( Foam::sqrt(m), GSL_PREC_DOUBLE );

    double A = 2.0/m - 1.0 - 3.0/m*E/K;

    // The value of 1.0e-8 is added to ensure strictly larger than 0!
    return 1.0 - 1.0e-8 + H/d*A;
}
double cnoidalFirst_f ( double m, void *params)
{
    struct cnoidalFirstParams *p = (struct cnoidalFirstParams * ) params;

    double T = p->period_;
    double d = p->depth_;
    double G = p->g_;
    double H = p->height_;

    double K = gsl_sf_ellint_Kcomp( Foam::sqrt(m), GSL_PREC_DOUBLE );
    double E = gsl_sf_ellint_Ecomp( Foam::sqrt(m), GSL_PREC_DOUBLE );

    double A = 2.0/m - 1.0 - 3.0/m*E/K;

    return T*Foam::sqrt(G/d)*Foam::sqrt(1.0 + H/d*A)
        - Foam::sqrt( 16.0*d/(3.0*H)*m * Foam::pow(K, 2.0) );
}
Beispiel #6
0
      /**
       * C++ version of gsl_sf_ellint_Kcomp().
       * Legendre form of complete elliptic integrals
       *
       * K(k) = Integral[1/Sqrt[1 - k^2 Sin[t]^2], {t, 0, Pi/2}]
       *
       * @param k A real number
       * @param mode The mode
       * @return function value
       */
      inline double Kcomp( double k, mode_t mode ){
	return gsl_sf_ellint_Kcomp( k, mode ); } 
Beispiel #7
0
 inline double set_vs( int is, int ns, double kprime ){
   double ekprime = gsl_sf_ellint_Kcomp( kprime , 0 ); 
   double vs = is * ekprime / ns; 
   return vs;
 }