当前位置: 首页>>代码示例>>C++>>正文


C++ Ostream::precision方法代码示例

本文整理汇总了C++中Ostream::precision方法的典型用法代码示例。如果您正苦于以下问题:C++ Ostream::precision方法的具体用法?C++ Ostream::precision怎么用?C++ Ostream::precision使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Ostream的用法示例。


在下文中一共展示了Ostream::precision方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: set

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 );
}
开发者ID:Aidan-Bharath,项目名称:waves2Foam,代码行数:59,代码来源:cnoidalFirstProperties.C


注:本文中的Ostream::precision方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。