Navigation

    CFD中文网

    CFD中文网

    • Login
    • Search
    • 最新

    [C++] VectorSpace.H

    OpenFOAM
    3
    5
    15856
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Wayne
      Wayne last edited by

      template<class Form, class Cmpt, int nCmpt>
      class VectorSpace
      {
      
      public:
      
      //- Component type
      typedef Cmpt cmptType;
      

      上面这句把模板参数 typedef 了,是做什么用呢?

      然后 cmptType 出现在同文件夹的 products.H 中,

      template<class arg1, class arg2>
      class outerProduct
      {
      public:
      
      typedef typename typeOfRank
      <
          typename pTraits<arg1>::cmptType,
          int(pTraits<arg1>::rank) + int(pTraits<arg2>::rank)
      >::type type;
      };
      

      这个 outerProduct 类怎么理解?

      Blog: http://blog.sina.com.cn/multiphyzks
      RG:https://www.researchgate.net/profile/Yan_Wang154

      李东岳 1 Reply Last reply Reply Quote
      • 李东岳
        李东岳 管理员 @Wayne last edited by 李东岳

        @Wayne Hi,

        我看了一下这个头文件。这个typeOfRank里面的int(pTraits<arg1>::rank) + int(pTraits<arg2>::rank)是具体的值,比如矢量的outerProduct的值为2,矢量的intterProduct的值为0. 也就是说矢量外积为张量,内积为标量。

        typedef Cmpt cmptType;单说这个就是给cmpt取个别名叫做cmptType,在使用的时候,可以直接用这个cmptType,就是cmpt,但是它会随着模板变化。或许查查其他的头文件,会有用到cmpttype?

        线上CFD课程 7月1日报名截止 http://dyfluid.com/class.html
        CFD高性能服务器 http://dyfluid.com/servers.html

        Wayne 1 Reply Last reply Reply Quote
        • Wayne
          Wayne @李东岳 last edited by

          @李东岳 多谢

          Blog: http://blog.sina.com.cn/multiphyzks
          RG:https://www.researchgate.net/profile/Yan_Wang154

          1 Reply Last reply Reply Quote
          • W
            wwzhao 教授 last edited by

            这个VectorSpace是OpenFOAM中的primitive type,所有的primitive type都需要能够使用C++的萃取(traits)技术提炼基本信息。

            话说OpenFOAM把C++的高级特性都用上了,这架构设计的水平实在是高!

            1 Reply Last reply Reply Quote
            • Wayne
              Wayne last edited by

              谢谢回答。现在知道把模板参数 typedef 是为了可以输出模板参数的类型。参见C++ traits

              Blog: http://blog.sina.com.cn/multiphyzks
              RG:https://www.researchgate.net/profile/Yan_Wang154

              1 Reply Last reply Reply Quote
              • First post
                Last post

              CFD中文网 | 东岳流体 | 京ICP备15017992号-2
              论坛登录问题反馈可联系 li.dy@dyfluid.com