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


C++ ScalarField::grid_params方法代码示例

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


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

示例1: deriv_yy

void deriv_yy(const ScalarField<T, S>& f, ScalarField<S, S>& out) {
  const GridParams& p = f.grid_params();
  assert(p == out.grid_params());
  assert(p.ny >= 3);

  const double d = 1./(p.eps_y*p.eps_y);

  for (int i = 0; i < p.nx; ++i) {
    for (int j = 0; j < p.ny; ++j) {
      T a, b, c;
      if (j == 0) {
        a = f(i,j);
        b = f(i,j+1);
        c = f(i,j+2);
      } else if (j == p.ny-1) {
        a = f(i,j-2);
        b = f(i,j-1);
        c = f(i,j);
      } else {
        a = f(i,j-1);
        b = f(i,j);
        c = f(i,j+1);
      }
      out(i,j) = (a - 2.*b + c) * d;
    }
  }
}
开发者ID:hojonathanho,项目名称:timb,代码行数:27,代码来源:grid.hpp

示例2: deriv_xx

void deriv_xx(const ScalarField<T, S>& f, ScalarField<S, S>& out) {
  const GridParams& p = f.grid_params();
  assert(p == out.grid_params());
  assert(p.nx >= 3);

  const double d = 1./(p.eps_x*p.eps_x);

  for (int i = 0; i < p.nx; ++i) {
    for (int j = 0; j < p.ny; ++j) {
      T a, b, c;
      if (i == 0) {
        a = f(i,j);
        b = f(i+1,j);
        c = f(i+2,j);
      } else if (i == p.nx-1) {
        a = f(i-2,j);
        b = f(i-1,j);
        c = f(i,j);
      } else {
        a = f(i-1,j);
        b = f(i,j);
        c = f(i+1,j);
      }
      out(i,j) = (a - 2.*b + c) * d;
    }
  }
}
开发者ID:hojonathanho,项目名称:timb,代码行数:27,代码来源:grid.hpp

示例3: apply_flow

void apply_flow(const ScalarField<ElemT, ExprT>& phi, const DoubleField& u_x, const DoubleField& u_y, ScalarField<ExprT, ExprT>& out) {
  const GridParams& gp = phi.grid_params();
  assert(u_x.grid_params() == gp && u_y.grid_params() == gp && out.grid_params() == gp);

  for (int i = 0; i < gp.nx; ++i) {
    for (int j = 0; j < gp.ny; ++j) {
      auto xy = gp.to_xy(i, j);
      out(i,j) = phi.eval_xy(xy.first - u_x(i,j), xy.second - u_y(i,j));
    }
  }
}
开发者ID:hojonathanho,项目名称:timb,代码行数:11,代码来源:grid.hpp

示例4: deriv_y

void deriv_y(const ScalarField<T, S>& f, ScalarField<S, S>& g_y) {
  const GridParams& p = f.grid_params();
  assert(p == g_y.grid_params());

  // derivatives in y direction
  for (int i = 0; i < p.nx; ++i) {
    for (int j = 0; j < p.ny - 1; ++j) {
      g_y(i,j) = (f(i,j+1) - f(i,j)) * (1./p.eps_y);
    }
    // copy over last column
    g_y(i,p.ny-1) = g_y(i,p.ny-2);
  }
}
开发者ID:hojonathanho,项目名称:timb,代码行数:13,代码来源:grid.hpp

示例5: deriv_x

void deriv_x(const ScalarField<T, S>& f, ScalarField<S, S>& g_x) {
  const GridParams& p = f.grid_params();
  assert(p == g_x.grid_params());

  // derivatives in x direction
  for (int i = 0; i < p.nx - 1; ++i) {
    for (int j = 0; j < p.ny; ++j) {
      g_x(i,j) = (f(i+1,j) - f(i,j)) * (1./p.eps_x);
    }
  }
  // copy over last row
  for (int j = 0; j < p.ny; ++j) {
    g_x(p.nx-1,j) = g_x(p.nx-2,j);
  }
}
开发者ID:hojonathanho,项目名称:timb,代码行数:15,代码来源:grid.hpp

示例6: deriv_y_central

void deriv_y_central(const ScalarField<T, S>& f, ScalarField<S, S>& g_y) {
  const GridParams& p = f.grid_params();
  assert(p == g_y.grid_params());

  // derivatives in y direction
  // forward/backward differences for edges, central for everything else
  for (int i = 0; i < p.nx; ++i) {
    for (int j = 0; j < p.ny; ++j) {
      if (j == 0) {
        g_y(i,j) = (f(i,j+1) - f(i,j)) * (1./p.eps_y);
      } else if (j == p.ny-1) {
        g_y(i,j) = (f(i,j) - f(i,j-1)) * (1./p.eps_y);
      } else {
        g_y(i,j) = (f(i,j+1) - f(i,j-1)) * (1./(2.*p.eps_y));
      }
    }
  }
}
开发者ID:hojonathanho,项目名称:timb,代码行数:18,代码来源:grid.hpp


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