📄 relax.c
字号:
#include "redblack2d.h"//// Fortran name mangling is architecture-specific, so define a mangled// name appropriate to your architecture//#if (defined(nCUBE2) || defined(CRAYC90))#define redblack5 REDBLACK5#define residual5 RESIDUAL5#else#define redblack5 redblack5_#define residual5 residual5_#endifextern "C" {void redblack5(double *u, const int *const nl, const int *const nh, const double *h, const int *const offset, double *du);}double relax(Grid2(double)& U, const double& h) { /* Call a Fortran routine to perform relaxation on the grid. This is an example of the C++ - Fortran interface. The C++ grid class uses Fortran-style array ordering of the indices. So, to call Fortran, we need to pass the beginning of the grid array and also the x and y dimensions of the array. The member function X.extents(Y), where X is a Region, returns the size of the Yth dimension of the Region object X. The member function X.data(), where X is a grid, returns a pointer the buffer holding the grid data of object X. Remember the parameter passing conventions in Fortran -- use pointers to scalars. redblack5 is a Fortran subroutine that performs a red-black jacobi update on a 2D array of REAL*8 values (see file rb5.F). */ const int red = 0, black = 1; double r0=0.0, r1=0.0; Region2 interior = grow(U.region(), -1); const Point2 nl = interior.lower(); const Point2 nh = interior.upper(); redblack5(U.data(), nl, nh, &h, &red, &r0); redblack5(U.data(), nl, nh, &h, &black, &r1); if (r1 > r0) r0 = r1; return(r0); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -