⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fdtdgen.h

📁 The tar file contains the following files: ptfsf.c: heart of the perfect TFSF code ptfsf.h: he
💻 H
字号:
/* fdtdgen.h: header file containing macro definitions used by
 *      numerous functions.
 *
 * Copyright (C) 2004 John B. Schneider
 *
 *********************************************************************
 * This program is free software; you can redistribute it and/or     *
 * modify it under the terms of the GNU General Public License       *
 * as published by the Free Software Foundation (FSF) version 2      *
 * of the License.                                                   *
 *                                                                   *
 * This program is distributed in the hope that it will be useful,   *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of    *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the     *
 * GNU General Public License for more details.                      *
 *                                                                   *
 * You should have received a copy of the GNU General Public License *
 * along with this program; if not, write to the Free Software       *
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA         *
 * 02111-1307, USA.  You may also visit the FSF web site at          *
 * www.fsf.org.  The license under which this software is publish    *
 * is available from www.fsf.org/copyleft/gpl.html or                *
 * www.fsf.org/copyleft/gpl.txt.                                     *
 *********************************************************************
 */


/********** 2- and 3-D array indexing macros. ************/
#define INDEX_3D(I,J,K,NX,NY,NZ) (((I)*(NY)+(J))*(NZ)+(K))
#define INDEX_2D(I,J,NX,NY) ((I)*(NY)+(J))

/********* 1-, 2-, and 3-D allocation macros. ************/
#define ALLOC_3D(name,nx,ny,nz,type) { \
 name = (type *)calloc((nx)*(ny)*(nz),sizeof(type)); \
 if (!name) { perror("ALLOC_3D"); \
              fprintf(stderr,"Allocation failed for " #name "\n"); \
              exit(-1); \
             }; \
 }

#define ALLOC_2D(name,nx,ny,type) { \
 name = (type *)calloc((nx)*(ny),sizeof(type)); \
 if (!name) { perror("ALLOC_2D"); \
              fprintf(stderr,"Allocation failed for " #name "\n"); \
              exit(-1); \
             }; \
 }

#define ALLOC_1D(name,nx,type) { \
 name = (type *)calloc(nx,sizeof(type)); \
 if (!name) { perror("ALLOC_1D"); \
              fprintf(stderr,"Allocation failed for " #name "\n"); \
              exit(-1); \
             }; \
 }

/* Same as above but allows a string to be given as first argument.  This
 * is useful is you want to specify some other bit of info -- such as the
 * the function name -- when making the call.
 */
#define ALLOC_1D_STRING(string,name,nx,type) {	\
 name = (type *)calloc(nx,sizeof(type)); \
 if (!name) { perror("ALLOC_1D_STRING"); \
              fprintf(stderr,#string \
                 "  Allocation failed for " #name ".  Terminating...");\
              exit(-1); \
             }; \
 }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -