现在的位置: 首页 > 综合 > 正文

Fluent 中的关键数据结构类型分析

2013年10月14日 ⁄ 综合 ⁄ 共 4534字 ⁄ 字号 评论关闭

 

Fluent 中最根本的类型要属 struct obj,来看看它的源码先。

 


 

struct obj
{
  union {
    struct {fixnum ncell; struct obj *vcell;} symbol;
    struct {struct obj *car; struct obj *cdr;} cons;
    struct {struct obj *env; struct obj *code;} closure;
    struct {fixnum ncell; struct obj *(*f)();} subr;
    struct {unsigned char data;}  character;
    struct {fixnum data;}   fixednum;
    struct {flonum data;}   floatnum;
    struct {fixnum ncell; fixnum length;} string;
    struct {fixnum ncell; fixnum length;} vector;
    struct {fixnum ncell; short valid;}  continuation;
    struct {fixnum ncell; struct obj *next;} free;
    struct {fixnum ncell;}   port;
    struct {fixnum id; char *data;}  foreign;
  } as;

  Sshortint gc_mark;
  Sshortint type;
};

 

 


 

它由三部分组成:联合体 as,GC 标记和类型编号。

 

其中 as 的变化很多,可以用来表示需要的各种类型数据。

 

下面是一些数据类型的编号:

 

 


 

#define tc_nil  0
#define tc_true  1
#define tc_false 31

#define tc_cons  2
#define tc_symbol 3
#define tc_flonum 4
#define tc_fixnum 5
#define tc_char  6
#define tc_string 7
#define tc_vector 8
#define tc_continuation 9
#define tc_nm_vector 10
#define tc_free  11
#define tc_port  12

#define tc_lambda 13
#define tc_closure 14
#define tc_quote 15
#define tc_define 16
#define tc_setq  17
#define tc_begin 18
#define tc_if  19
#define tc_and  20
#define tc_or  21
#define tc_tenv  22
#define tc_access 23
#define tc_apply 24

#define tc_subr_0 25
#define tc_subr_1 26
#define tc_subr_2 27
#define tc_subr_3 28
#define tc_subr_4 29
#define tc_fsubr 30
#define tc_lsubr 32

#define tc_foreign 33

 


 

要说 Fluent 的数据结构,主要看其如何存储网格和模型信息。

 

这里先看看 Domain 相关的数据结构。

 


typedef struct domain_struct
{
  /* Note: order of cell and face threads below must be
   * maintained for thread_loop macros; modify TL_* masks
   * when modifying.  (Should perhaps rewrite as array
   * of threads.)
   */
  struct thread_struct *c;          /* cell thread list */
  struct thread_struct *nosolve_c;  /* no solver cell thread list */
  struct thread_struct *nosolve_ext_c; /* no solver exterior cell thread */
  struct thread_struct *f;        /* face thread list */
  struct thread_struct *nosolve_f;  /* no solver face thread list */
#if RP_NETWORK
  struct thread_struct *nwc;         /* network cell */
  struct thread_struct *nwf;         /* network face */
#endif

#if RP_HANG
  struct objp_struct *bridge_fl;    /* hanging node bridge faces */
#endif
#if RP_NODE
  struct objp_struct *ext_vl;
  struct objp_struct *ext_fl;
  struct objp_struct *corner_vl;
# if RP_HANG && RP_EDGE
  struct objp_struct *corner_el;
# endif
  struct dom_neighbor_struct *neighbors; /* phasing out */
#if NEW_PARALLEL_NEIGHBOR
  struct domain_neighbor_struct *neighbor;
#endif /* NEW_PARALLEL_NEIGHBOR */
#endif

  struct domain_struct *_coarse;/* coarser domain (FAS MG) */
  struct domain_struct *_fine;    /* finer domain (FAS MG) */
  int mg_level;            /* grid level; 0 is finest level */

  real dtmin;            /* global minimum timestep */

#if RP_HOST
  int cell_count, face_count;
#endif
  int node_count;
  int nosolve_face_count, nosolve_cell_count;
#if RP_EDGE
  int edge_count;
#endif
#if RP_HANG
  int bridge_face_count;
#endif
#if RP_NODE
  int neighbor_count;
  int corner_node_count;
# if RP_HANG && RP_EDGE
  int corner_edge_count;
# endif /* RP_HANG && RP_EDGE */
#endif /* RP_NODE */
  struct timer_struct flow_timer, case_timer, data_timer;
#if !RP_HOST
  cxboolean active;
#else
  cxboolean *active;
#endif /* RP_HOST */
  struct storage_marker_struct sm[SM_MAX];
  struct sliding_interface *sliding_interfaces;
#if RP_DYNAMIC_MESH
  struct dynamic_thread_struct *dynamic_threads;
#endif

  int id;     /* id number (unique id for each domain)                    */
  int index;     /* index with respect to place within list of sub-domains
          * of parent - i.e. phase index.
          * domains that are not sub-domain (e.g. top-level mixture
          * or single fluid) have index = NULL_INDEX                 */
  int level;     /* level (e.g. how far above root)                          */
  int n_domains; /* number of sub domains branching from this domain         */

/* pointers to sub-domains; max size +1 used to permit less
   complicated logic in the third expression of the for loops
   used in the sub domain loop macros */
  struct domain_struct *sub_domains[MAX_SUB_DOMAINS+1];

  struct domain_struct *interaction;   /* phase interactions domain */

  struct domain_struct *superdomain;   /* pointer back to superdomain  */

  struct domain_global_flags globals;  /* global flags */

  char name[MATERIAL_NAME_LENGTH];
  char material_name[MATERIAL_NAME_LENGTH];
  cxboolean model[DOMAIN_MODEL_MAX];

  Species_Model species_model;

  Property property[PROP_MAX];
  Property *complex_property[COMPLEX_PROP_MAX];

  /* residuals */
  real *res[MAX_EQNS];
#if RP_NODE
  real *gres[MAX_EQNS];
#endif
  real rtrms[MAX_EQNS];
  real rtrms_final[MAX_EQNS];
#if RP_NODE
  real grtrms[MAX_EQNS];
  real grtrms_final[MAX_EQNS];
#endif
  real *res_scale[MAX_EQNS];
  real rscale[MAX_EQNS];
#if RP_NODE
  real *gres_scale[MAX_EQNS];
  real grscale[MAX_EQNS];
#endif
  char equation_labels[MAX_EQNS][32];

  void *CellFunc;     /* Pointer to CELL_FUNCTION array */
  int NCellFunc;      /* total number of cell function */

} Domain;

 


 

 

 

抱歉!评论已关闭.