k-dot-p 0.1

kdotp::libmodelxx::grid Namespace Reference

Classes

class  cartesian_grid
struct  grid
struct  point
union  value
struct  key_value
struct  shape
struct  shape_block
struct  shape_global
struct  shape_tree

Enumerations

enum  grid_type { CARTESIAN }
enum  value_type {
  STRING, INT, FLOAT, VECTOR,
  VECTOR_SET, SHAPE
}
enum  shape_type { INVALID = -1, GLOBAL, BLOCK, ABSBLOCK }
enum  shape_operation {
  OR, XOR, AND, NOT,
  LEAF
}

Functions

char * long_unsigned_to_string (long unsigned *val)
template<typename T , unsigned Nc = 1>
void * set_up_grid (struct grid *g, T defvalue, GError **err)
template<typename T , unsigned Nc = 1>
GError * free_grid_class (enum grid_type t, int dims, void *grid_class)
template<typename T , unsigned Nc = 1>
GError * set_value_in_grid (enum grid_type t, int dims, void *grid_class, const struct shape_tree *st, T value, GHashTable *global_symbol_table)
template<typename T , unsigned Nc = 1>
GError * set_value_in_grid (enum grid_type t, int dims, void *grid_class, const struct shape_tree *st, struct::kdotp::libmodelxx::postprocessing::function_exp *exp, GHashTable *global_symbol_table, GError *(*set_location_from_double)(T *, double *, int, void *), void *privdat)
template<typename T , unsigned Nc = 1>
GError * dump_grid (GOutputStream *gos, enum grid_type t, int dims, void *grid_class, char *(*t_to_str)(T *))
template<typename T , unsigned Nc = 1>
GError * dump_indexed_grid (GOutputStream *gos, enum grid_type t, int dims, void *grid_class, bool is_same(T *, T *), char *(*t_to_str)(T *))
void print_vector (GList *l)
void print_vector_list (GList *l)
void print_key_value (const struct key_value *kvi)
void print_key_value_list (GList *l)
void key_value_free (struct key_value *kv)
struct shape_blockmake_block_from_shape (struct shape *s, int dim, bool abs)
struct shape_globalmake_global_from_shape (struct shape *s, int dim)
struct shape_treepostprocess_shape_tree (struct shape_tree *st, int dim)
void shape_block_free (struct shape_block *b)
void shape_global_free (struct shape_global *b)
void shape_free (struct shape *s)
void shape_tree_free (struct shape_tree *st)
enum shape_type get_shape_from_identifier (const char *identifier)
void get_string_from_shape_type (char **str, enum shape_type t)

Enumeration Type Documentation

Enumerator:
CARTESIAN 

Definition at line 37 of file grid.h++.

                     {
  CARTESIAN
      };
Enumerator:
OR 
XOR 
AND 
NOT 
LEAF 

Definition at line 47 of file shapes.h++.

                           {
  OR,             //Total shape is an OR of the individual shapes
  XOR,
  AND,
  NOT,             //Unary not; operatos on l, not r (r=NULL)
  LEAF             //special "type"; a LEAF is just a plain shape.
      };
Enumerator:
INVALID 
GLOBAL 
BLOCK 
ABSBLOCK 

Definition at line 39 of file shapes.h++.

                      {
  INVALID=-1,
  GLOBAL,       //Puts this material everywhere
  BLOCK,          //Block type shape
  ABSBLOCK      //Absolutely-positioned Block type shape
      };
Enumerator:
STRING 
INT 
FLOAT 
VECTOR 
VECTOR_SET 
SHAPE 

Definition at line 32 of file key_values.h++.


Function Documentation

template<typename T , unsigned Nc = 1>
GError* kdotp::libmodelxx::grid::dump_grid ( GOutputStream *  gos,
enum grid_type  t,
int  dims,
void *  grid_class,
char *(*)(T *)  t_to_str 
)

Definition at line 210 of file grid.h++.

References CARTESIAN, kdp::constants::e, and GERROR_DOMAIN_LIBMODELXX_GRID.

                                                                                                                 {
  GError *err=NULL, *e=NULL;
      switch(t){
  case CARTESIAN:
    switch(dims){
    case 1:
      if((err=static_cast<cartesian_grid<T, 1, Nc>*>(grid_class)->dump(gos, t_to_str))) {
        g_propagate_prefixed_error(&e, err, "kdotp::libmodelxx::grid::dump_grid(expression): failed to dump 1D cartesian grid: ");
        return err;
      }
      return NULL;
    case 2:
      if((err=static_cast<cartesian_grid<T, 2, Nc>*>(grid_class)->dump(gos, t_to_str))) {
        g_propagate_prefixed_error(&e, err, "kdotp::libmodelxx::grid::dump_grid(expression): failed to dump 2D cartesian grid: ");
        return err;
      }
      return NULL;
    case 3:
      if((err=static_cast<cartesian_grid<T, 3, Nc>*>(grid_class)->dump(gos, t_to_str))) {
        g_propagate_prefixed_error(&e, err, "kdotp::libmodelxx::grid::dump_grid(expression): failed to dump 3D cartesian grid: ");
        return err;
      }
      return NULL;
    default:
      return g_error_new(GERROR_DOMAIN_LIBMODELXX_GRID, 1, "kdotp::libmodelxx::grid::dump_grid(expression): ERROR setting up cartesian grid: bad number of dimensions (%d); must be in range (1, 3).\n", dims);
    }
    break;
  default:
    return g_error_new(GERROR_DOMAIN_LIBMODELXX_GRID, 2, "kdotp::libmodelxx::grid::dump_grid(expression): ERROR no such grid (numeric equivalent is %d)\n\tThis is almost certainly a programming error and/or an input error (shouldn't have let the bad input through)\n", t);
  }
  return NULL;
      }
template<typename T , unsigned Nc = 1>
GError* kdotp::libmodelxx::grid::dump_indexed_grid ( GOutputStream *  gos,
enum grid_type  t,
int  dims,
void *  grid_class,
bool   is_sameT *, T *,
char *(*)(T *)  t_to_str 
)

Definition at line 244 of file grid.h++.

References CARTESIAN, kdp::constants::e, and GERROR_DOMAIN_LIBMODELXX_GRID.

                                                                                                                                               {
  GError *err=NULL, *e=NULL;
  switch(t){
  case CARTESIAN:
    switch(dims){
    case 1:
      if((err=static_cast<cartesian_grid<T, 1, Nc>*>(grid_class)->dump_indexed(gos, is_same, t_to_str))) {
        g_propagate_prefixed_error(&e, err, "kdotp::libmodelxx::grid::dump_indexed_grid(expression): failed to dump indexed 1D cartesian grid: ");
        return err;
      }
      return NULL;
    case 2:
      if((err=static_cast<cartesian_grid<T, 2, Nc>*>(grid_class)->dump_indexed(gos, is_same, t_to_str))) {
        g_propagate_prefixed_error(&e, err, "kdotp::libmodelxx::grid::dump_indexed_grid(expression): failed to dump indexed 2D cartesian grid: ");
        return err;
      }
      return NULL;
    case 3:
      if((err=static_cast<cartesian_grid<T, 3, Nc>*>(grid_class)->dump_indexed(gos, is_same, t_to_str))) {
        g_propagate_prefixed_error(&e, err, "kdotp::libmodelxx::grid::dump_indexed_grid(expression): failed to dump indexed 3D cartesian grid: ");
        return err;
      }
      return NULL;
    default:
      return g_error_new(GERROR_DOMAIN_LIBMODELXX_GRID, 1, "kdotp::libmodelxx::grid::dump_indexed_grid(expression): ERROR setting up cartesian grid: bad number of dimensions (%d); must be in range (1, 3).\n", dims);
    }
    break;
  default:
    return g_error_new(GERROR_DOMAIN_LIBMODELXX_GRID, 2, "kdotp::libmodelxx::grid::dump_indexed_grid(expression): ERROR no such grid (numeric equivalent is %d)\n\tThis is almost certainly a programming error and/or an input error (shouldn't have let the bad input through)\n", t);
  }
  return NULL;
      }
template<typename T , unsigned Nc = 1>
GError* kdotp::libmodelxx::grid::free_grid_class ( enum grid_type  t,
int  dims,
void *  grid_class 
)

Definition at line 106 of file grid.h++.

References CARTESIAN, and GERROR_DOMAIN_LIBMODELXX_GRID.

                                                                            {
  switch(t) {
  case CARTESIAN:
    switch(dims){
    case 1:
      delete (cartesian_grid<T, 1, Nc>*)grid_class;
      return NULL;
    case 2:
      delete (cartesian_grid<T, 2, Nc>*)grid_class;
      return NULL;
    case 3:
      delete (cartesian_grid<T, 3, Nc>*)grid_class;
      return NULL;
    default:
      return g_error_new(GERROR_DOMAIN_LIBMODELXX_GRID, 1, "kdotp::libmodelxx::continuous_structure::free_grid: ERROR freeing cartesian grid: bad number of dimensions (%d); must be in range (1, 3).", dims);
    }
    break;
  default:
    return g_error_new(GERROR_DOMAIN_LIBMODELXX_GRID, 2, "kdotp::libmodelxx::continuous_structure::free_grid: ERROR no such grid (numeric equivalent is %d)\n\tThis is almost certainly a programming error and/or an input error (shouldn't have let the bad input through)", t);
  }
  return NULL;
      }
enum shape_type kdotp::libmodelxx::grid::get_shape_from_identifier ( const char *  identifier)

Definition at line 203 of file shapes.c++.

References ABSBLOCK, BLOCK, GLOBAL, and INVALID.

Referenced by yyparse().

                                                                        {
  if(!g_ascii_strcasecmp(identifier, "block")){
    return BLOCK;
  }else if(!g_ascii_strcasecmp(identifier, "absblock")){
    return ABSBLOCK;
  }else if(!g_ascii_strcasecmp(identifier, "global")){
    return GLOBAL;
  }
  return INVALID;
      }

Here is the caller graph for this function:

void kdotp::libmodelxx::grid::get_string_from_shape_type ( char **  str,
enum shape_type  t 
)

Definition at line 215 of file shapes.c++.

References ABSBLOCK, BLOCK, GLOBAL, and INVALID.

Referenced by yyparse().

                                                                     {
        GString *s = NULL;
  switch(t) {
  case INVALID:
    s = g_string_new("invalid");
    break;
  case BLOCK:
    s = g_string_new("block");
    break;
  case ABSBLOCK:
    s = g_string_new("absblock");
    break;
  case GLOBAL:
    s = g_string_new("global");
    break;
  default:
    s = g_string_new("unkdnown(");
    g_string_append_printf(s, "%d)", t);
  }
  *str = s->str;
  g_string_free(s, FALSE);
      }

Here is the caller graph for this function:

void kdotp::libmodelxx::grid::key_value_free ( struct key_value *  kv)

Frees a key/value struct and its data.

Definition at line 81 of file key_values.c++.

References FLOAT, INT, kdotp::libmodelxx::grid::key_value::key, kdotp::libmodelxx::grid::value::l, kdotp::libmodelxx::grid::value::s, SHAPE, shape_tree_free(), kdotp::libmodelxx::grid::value::st, STRING, kdotp::libmodelxx::grid::key_value::t, kdotp::libmodelxx::grid::key_value::value, VECTOR, and VECTOR_SET.

                                                {
  GList* l;
  GList* ll;
  if((kv->key) != NULL) free(kv->key);
  switch(kv->t) {
  case STRING:
    free(kv->value.s);
    break;
  case VECTOR:
    for(ll=kv->value.l; ll != NULL; ll=ll->next) {
      free((double*)ll->data);
    }
    break;
  case VECTOR_SET:
    for(l=kv->value.l; l!=NULL; l=l->next) {
      for(ll=(GList*)(l->data); ll != NULL; ll=ll->next) {
        free((double*)ll->data);
      }
    }
    break;
  case SHAPE:
    shape_tree_free(kv->value.st);
    break;
  case INT:
  case FLOAT:
    /*These aren't pointers; nothing to de-allocate*/
    break;
  default:
    fprintf(stderr, "kdotp::libmodelxx::grid::key_value_free: WARNING: didn't recognize the value in key_value (numeric %d)!\n", kv->t);
  }
      }

Here is the call graph for this function:

char * kdotp::libmodelxx::grid::long_unsigned_to_string ( long unsigned *  val)

Definition at line 30 of file cartesian_grid.c++.

References str.

Referenced by kdotp::libmodelxx::grid::cartesian_grid< libmodelxx::structure::material *, 1, 1 >::dump_indexed().

                                                        {
  GString *s = g_string_new_len("", 1024);
  g_string_printf(s, "%lu", *val);
  char* str = s->str;
  g_string_free(s, FALSE);
  return str;
      }

Here is the caller graph for this function:

struct shape_block* kdotp::libmodelxx::grid::make_block_from_shape ( struct shape *  s,
int  dim,
bool  abs 
) [read]

Definition at line 34 of file shapes.c++.

References ABSBLOCK, BLOCK, kdotp::libmodelxx::grid::shape_block::center, kdotp::libmodelxx::grid::shape::descriptor, kdotp::libmodelxx::postprocessing::function_print_tree(), kdotp::libmodelxx::grid::shape_block::generic, kdotp::libmodelxx::grid::shape_block::L, LEAF, kdotp::libmodelxx::grid::shape_block::op, str, and kdotp::libmodelxx::grid::shape_block::type.

Referenced by postprocess_shape_tree().

                                                                                    {
  shape_block* b = (struct shape_block*)malloc(sizeof(struct shape_block));
  b->op = LEAF;
  if(abs) {
    b->type = ABSBLOCK;
  }else{
    b->type = BLOCK;
  }
  b->generic = false;
  b->center = (struct function_exp*)malloc(sizeof(struct function_exp));
  if((b->center == NULL)) {
    if(abs) {
      fprintf(stderr, "kdotp::libmodelxx::grid::make_block_from_shape: ERROR allocating memory for first corner coordinate\n");
    }else{
      fprintf(stderr, "kdotp::libmodelxx::grid::make_block_from_shape: ERROR allocating memory for center\n");
    }
    exit(15);
  }
  b->L = (struct function_exp*)malloc(sizeof(struct function_exp));
  if((b->L == NULL)) {
    if(abs) {
      fprintf(stderr, "kdotp::libmodelxx::grid::make_block_from_shape: ERROR allocating memory for second corner coordinate\n");
    }else{
      fprintf(stderr, "kdotp::libmodelxx::grid::make_block_from_shape: ERROR allocating memory for L\n");
    }
    exit(16);
  }
  /*There should be two vectors: the center of the box, and the width
   *  of the box (vector from one corner to the other)
   *As a convenience, the vectors may be scalars if there is only
   *  one dimension
   */
  GString* str = g_string_new("");
  GList *l = s->descriptor;
  if(l == NULL) {
    fprintf(stderr, "kdotp::libmodelxx::grid::make_global_from_shape: ERROR: insufficient shape description was given to a \"block\" or \"absblock\" shape, which takes only two vectors. This superfluous information will be ignored.\n");
    exit(17);
  }
  b->center = (struct function_exp*)(l->data);
  function_print_tree(b->center, &str, 1);
  fprintf(stderr, "b->center:\n%s\n", str->str);
  g_string_free(str, TRUE);
  l = l->next;
  if(l == NULL) {
    fprintf(stderr, "kdotp::libmodelxx::grid::make_global_from_shape: ERROR: insufficient shape description was given to a \"block\" or \"absblock\" shape, which takes only two vectors. This superfluous information will be ignored.\n");    exit(18);
  }
  b->L = (struct function_exp*)(l->data);
  str = g_string_new("");
  function_print_tree(b->L, &str, 1);
  fprintf(stderr, "b->L:\n%s\n", str->str);
  g_string_free(str, TRUE);
  l=l->next;
  if(l != NULL) {
    fprintf(stderr, "kdotp::libmodelxx::grid::make_global_from_shape: WARNING: extra shape description was given to a \"block\" shape, which takes only two vectors. This superfluous information will be ignored.\n");
  }
  return b;
      }

Here is the call graph for this function:

Here is the caller graph for this function:

struct shape_global* kdotp::libmodelxx::grid::make_global_from_shape ( struct shape *  s,
int  dim 
) [read]

Definition at line 91 of file shapes.c++.

References kdotp::libmodelxx::grid::shape::descriptor, g, kdotp::libmodelxx::grid::shape_global::generic, GLOBAL, LEAF, kdotp::libmodelxx::grid::shape_global::op, and kdotp::libmodelxx::grid::shape_global::type.

Referenced by postprocess_shape_tree().

                                                                            {
  shape_global* g = (struct shape_global*)malloc(sizeof(struct shape_global));
  g->op = LEAF;
  g->type = GLOBAL;
  g->generic = false;
  if((s->descriptor) != NULL) {
    fprintf(stderr, "kdotp::libmodelxx::grid::make_global_from_shape: WARNING: a shape description was given to a \"global\" shape, which takes no description. This superfluous information will be ignored.\n");
  }
  return g;
      }

Here is the caller graph for this function:

struct shape_tree * kdotp::libmodelxx::grid::postprocess_shape_tree ( struct shape_tree *  st,
int  dim 
) [read]
Note:
Algorithm: 1) Recurse on non-leaf nodes 2) Set l, r from recursion. 3) If leaf, set the respective type using above helper function.
caller MUST set the return value; you may just have a leaf node.

Definition at line 109 of file shapes.c++.

References ABSBLOCK, BLOCK, kdotp::libmodelxx::grid::shape::generic, GLOBAL, kdotp::libmodelxx::grid::shape_tree::l, LEAF, make_block_from_shape(), make_global_from_shape(), kdotp::libmodelxx::grid::shape_tree::op, kdotp::libmodelxx::grid::shape_tree::r, shape_free(), and kdotp::libmodelxx::grid::shape::type.

Referenced by kdotp::libmodelxx::continuous_structure::postprocess_structure().

                                                                                {
  /*Simple bounce for NULL links.*/
  if(st == NULL) return NULL;
  if(st->op != LEAF) {
    if(st->l == NULL){
      fprintf(stderr, "kdotp::libmodelxx::grid::postprocess_shape_tree: left subtree of a non-LEAF shape tree node should never be NULL, but is! (op is %d)\n", st->op);
      return NULL;
    }
    if(((st->l) = postprocess_shape_tree(st->l, dim)) != NULL) {
      /*If this was already NULL, we're fine.*/
      if((st->r == NULL) || (((st->r) = postprocess_shape_tree(st->r, dim)) != NULL)) {
        return st;
      }else{
        fprintf(stderr, "kdotp::libmodelxx::grid::postprocess_shape_tree: got NULL postprocessing right subtree (op is %d)\n", st->op);
      }
    }else{
      fprintf(stderr, "kdotp::libmodelxx::grid::postprocess_shape_tree: got NULL postprocessing left subtree (op is %d)\n", st->op);
    }
    /*If we get to here, one or the other of the ones failed.*/
    return NULL;
  }
  /*This will only execute for leaf nodes.*/
  struct shape* s = (struct shape*)st;
  if(!(s->generic)) {
    fprintf(stderr, "kdotp::libmodelxx::grid::postprocess_shape_tree: WARNING shape is not generic, although it's expected to be!\n");
    /*For some reason, this shape has already been
     *postprocessed.  Just return it, then.
     */
    return st;
  }
  struct shape* n = NULL;
  switch (s->type) {
  case BLOCK:
    n = (struct shape*)make_block_from_shape(s, dim, false);
    break;
  case ABSBLOCK:
    n = (struct shape*)make_block_from_shape(s, dim, true);
    break;
  case GLOBAL:
    n = (struct shape*)make_global_from_shape(s, dim);
    break;
  default:
    fprintf(stderr, "kdotp::libmodelxx::grid::process_shape_tree: ERROR unrecognized shape type (numeric: %d)\n", s->type);
    return NULL;
  }
  shape_free(s);
  return (struct shape_tree*)n;
      }

Here is the call graph for this function:

Here is the caller graph for this function:

void kdotp::libmodelxx::grid::print_key_value ( const struct key_value *  kvi)

Pretty-prints a key/value pair

Parameters:
kvipointer to key_value struct holding the key/value pair

Definition at line 54 of file key_values.c++.

References kdotp::libmodelxx::grid::value::d, kdotp::libmodelxx::grid::value::i, INT, kdotp::libmodelxx::grid::key_value::key, kdotp::libmodelxx::grid::value::l, print_vector(), print_vector_list(), kdotp::libmodelxx::grid::value::s, SHAPE, STRING, kdotp::libmodelxx::grid::key_value::t, kdotp::libmodelxx::grid::key_value::value, VECTOR, and VECTOR_SET.

Referenced by print_key_value_list().

                                                        {
  if(kvi->t == STRING) {
    fprintf(stderr, "(%s=%s) ", kvi->key, kvi->value.s);
  } else if(kvi->t == INT) {
    fprintf(stderr, "(%s=%d) ", kvi->key, kvi->value.i);
  } else if(kvi->t == VECTOR) {
    fprintf(stderr, "(%s=", kvi->key);
    print_vector(kvi->value.l);
  } else if(kvi->t == VECTOR_SET) {
    fprintf(stderr, "(%s=", kvi->key);
    print_vector_list(kvi->value.l);
  } else if(kvi->t == SHAPE) {
    fprintf(stderr, "(<shape>)\n");
  } else {
    /*Double*/
    fprintf(stderr, "(%s=%g) ", kvi->key, kvi->value.d);
  }
      }

Here is the call graph for this function:

Here is the caller graph for this function:

void kdotp::libmodelxx::grid::print_key_value_list ( GList *  l)

Pretty-prints a list of key/value pairs

Parameters:
lGList storing the list of key/value pairs (data is pointer to GList of struct key/value pairs)

Definition at line 73 of file key_values.c++.

References print_key_value().

                                          {
  GList* i;
  for(i=l; l!=NULL; l=l->next) {
    print_key_value((struct key_value *)(l->data));
  }
      }

Here is the call graph for this function:

void kdotp::libmodelxx::grid::print_vector ( GList *  l)

Pretty-prints a vector to stderr

Parameters:
lGList storing the vector (data is pointer to double)

Definition at line 36 of file key_values.c++.

Referenced by print_key_value(), and print_vector_list().

                                  {
  GList* i;
  fprintf(stderr, "<");
  for(i=l; l!=NULL; l=l->next) {
    fprintf(stderr, "%g ", *((double*)(l->data)));
  }
  fprintf(stderr, ">\n");
      }

Here is the caller graph for this function:

void kdotp::libmodelxx::grid::print_vector_list ( GList *  l)

Pretty-prints a list of vectors to stderr

Parameters:
lGList storing the list of vectors (data is pointer to GList of doubles)

Definition at line 45 of file key_values.c++.

References print_vector().

Referenced by print_key_value().

                                       {
  GList* i;
  fprintf(stderr, "< ");
  for(i=l; l!=NULL; l=l->next) {
    print_vector((GList*)(l->data));
  }
  fprintf(stderr, " >\n");
      }

Here is the call graph for this function:

Here is the caller graph for this function:

template<typename T , unsigned Nc = 1>
void* kdotp::libmodelxx::grid::set_up_grid ( struct grid *  g,
defvalue,
GError **  err 
)

Sets up a grid that has been read in from a file

Parameters:
ggrid structure from the input file
Returns:
int error code: 0: success Creates the grid on which we're going to hang the semiconductor.
  • g pointer to the raw grid structure from the structspec
  • err pointer to a GError containing the error.
pointer to the new grid class
Note:
the default material is NULL; this will help us find any unassigned places.
Error values; NULL if successful 1 if there were too many/few dimensions specified 2 if the grid type is unsupported.

Definition at line 81 of file grid.h++.

References CARTESIAN, and GERROR_DOMAIN_LIBMODELXX_GRID.

                                                                  {
  switch(g->t) {
  case CARTESIAN:
    switch(g->dimensions){
    case 1:
      return new cartesian_grid<T, 1, Nc>(g->box_size, g->site_length, defvalue);
      break;
    case 2:
      return new cartesian_grid<T, 2, Nc>(g->box_size, g->site_length, defvalue);
      break;
    case 3:
      return new cartesian_grid<T, 3, Nc>(g->box_size, g->site_length, defvalue);
      break;
    default:
      *err = g_error_new(GERROR_DOMAIN_LIBMODELXX_GRID, 1, "kdotp::libmodelxx::continuous_structure::set_up_grid: ERROR setting up cartesian grid: bad number of dimensions (%d); must be in range (1, 3).", g->dimensions);
      return NULL;
    }
    break;
  default:
    *err = g_error_new(GERROR_DOMAIN_LIBMODELXX_GRID, 2, "kdotp::libmodelxx::continuous_structure::set_up_grid: ERROR no such grid (numeric equivalent is %d)\n\tThis is almost certainly a programming error and/or an input error (shouldn't have let the bad input through)", g->t);
  }
  return NULL;
      }
template<typename T , unsigned Nc = 1>
GError* kdotp::libmodelxx::grid::set_value_in_grid ( enum grid_type  t,
int  dims,
void *  grid_class,
const struct shape_tree *  st,
value,
GHashTable *  global_symbol_table 
)

Generic set_region

Parameters:
sshape_tree
mmaterial
Returns:
0 if success

Definition at line 138 of file grid.h++.

References CARTESIAN, and GERROR_DOMAIN_LIBMODELXX_GRID.

Referenced by kdotp::libmodelxx::continuous_structure::postprocess_structure().

                                                                                                                                                     {
  int err = 0;
  switch(t){
  case CARTESIAN:
    switch(dims){
    case 1:
      if((err=static_cast<cartesian_grid<T, 1, Nc>*>(grid_class)->set_points(st, &value, global_symbol_table)) != 0) {
        return g_error_new(GERROR_DOMAIN_LIBMODELXX_GRID, 10+err, "kdotp::libmodelxx::grid::set_value_in_grid: failed to execute set_points in 1D cartesian grid; err %d", err);
      }
      return NULL;
    case 2:
      if((err=static_cast<cartesian_grid<T, 2, Nc>*>(grid_class)->set_points(st, &value, global_symbol_table)) != 0) {
        return g_error_new(GERROR_DOMAIN_LIBMODELXX_GRID, 10+err, "kdotp::libmodelxx::grid::set_value_in_grid: failed to execute set_points in 2D cartesian grid; err %d", err);
      }
      return NULL;
    case 3:
      if((err=static_cast<cartesian_grid<T, 3, Nc>*>(grid_class)->set_points(st, &value, global_symbol_table)) != 0) {
        return g_error_new(GERROR_DOMAIN_LIBMODELXX_GRID, 10+err, "kdotp::libmodelxx::grid::set_value_in_grid: failed to execute set_points in 3D cartesian grid; err %d", err);
      }
      return NULL;
    default:
      return g_error_new(GERROR_DOMAIN_LIBMODELXX_GRID, 1, "kdotp::libmodelxx::grid::set_value_in_grid: ERROR setting up cartesian grid: bad number of dimensions (%d); must be in range (1, 3).\n", dims);
    }
    break;
  default:
    return g_error_new(GERROR_DOMAIN_LIBMODELXX_GRID, 2, "kdotp::libmodelxx::grid::set_value_in_grid: ERROR no such grid (numeric equivalent is %d)\n\tThis is almost certainly a programming error and/or an input error (shouldn't have let the bad input through)\n", t);
  }
  return NULL;
      }

Here is the caller graph for this function:

template<typename T , unsigned Nc = 1>
GError* kdotp::libmodelxx::grid::set_value_in_grid ( enum grid_type  t,
int  dims,
void *  grid_class,
const struct shape_tree *  st,
struct::kdotp::libmodelxx::postprocessing::function_exp *  exp,
GHashTable *  global_symbol_table,
GError *(*)(T *, double *, int, void *)  set_location_from_double,
void *  privdat 
)

set_region from an expression and a conversion from a double

Parameters:
sshape_tree
mmaterial
Returns:
0 if success

Definition at line 175 of file grid.h++.

References CARTESIAN, kdp::constants::e, and GERROR_DOMAIN_LIBMODELXX_GRID.

                                                                                                                                                                                                                                                                               {
  GError *err=NULL, *e=NULL;
  switch(t){
  case CARTESIAN:
    switch(dims){
    case 1:
      if((err=static_cast<cartesian_grid<T, 1, Nc>*>(grid_class)->set_points(st, exp, global_symbol_table, set_location_from_double, privdat)) != NULL) {
        g_propagate_prefixed_error(&e, err, "kdotp::libmodelxx::grid::set_value_in_grid(expression): failed to execute set_points in 1D cartesian grid: ");
        return err;
      }
      return NULL;
    case 2:
      if((err=static_cast<cartesian_grid<T, 2, Nc>*>(grid_class)->set_points(st, exp, global_symbol_table, set_location_from_double, privdat)) != NULL) {
        g_propagate_prefixed_error(&e, err, "kdotp::libmodelxx::grid::set_value_in_grid(expression): failed to execute set_points in 2D cartesian grid: ");
        return err;
      }
      return NULL;
    case 3:
      if((err=static_cast<cartesian_grid<T, 3, Nc>*>(grid_class)->set_points(st, exp, global_symbol_table, set_location_from_double, privdat)) != NULL) {
        g_propagate_prefixed_error(&e, err, "kdotp::libmodelxx::grid::set_value_in_grid(expression): failed to execute set_points in 3D cartesian grid: ");
        return err;
      }
      return NULL;
    default:
      return g_error_new(GERROR_DOMAIN_LIBMODELXX_GRID, 1, "kdotp::libmodelxx::grid::set_value_in_grid(expression): ERROR setting up cartesian grid: bad number of dimensions (%d); must be in range (1, 3).\n", dims);
    }
    break;
  default:
    return g_error_new(GERROR_DOMAIN_LIBMODELXX_GRID, 2, "kdotp::libmodelxx::grid::set_value_in_grid(expression): ERROR no such grid (numeric equivalent is %d)\n\tThis is almost certainly a programming error and/or an input error (shouldn't have let the bad input through)\n", t);
  }
  return NULL;
      }
void kdotp::libmodelxx::grid::shape_block_free ( struct shape_block *  b)

Definition at line 158 of file shapes.c++.

References kdotp::libmodelxx::grid::shape_block::center, kdotp::libmodelxx::postprocessing::free_function(), and kdotp::libmodelxx::grid::shape_block::L.

Referenced by shape_free().

                                                   {
  free_function(b->center);
  free_function(b->L);
  free(b);
      }

Here is the call graph for this function:

Here is the caller graph for this function:

void kdotp::libmodelxx::grid::shape_free ( struct shape *  s)

Definition at line 169 of file shapes.c++.

References ABSBLOCK, BLOCK, kdotp::libmodelxx::grid::shape::descriptor, kdotp::libmodelxx::grid::shape::generic, GLOBAL, shape_block_free(), shape_global_free(), kdotp::libmodelxx::grid::shape_block::type, and kdotp::libmodelxx::grid::shape::type.

Referenced by postprocess_shape_tree(), and shape_tree_free().

                                       {
  /*Free the value list.*/
  GList* l;
  if(s->generic){
    /*The functions are moved over to the new structure; just free the list.*/
    g_list_free(s->descriptor);
  }else{
    switch(s->type){
    case GLOBAL:
      shape_global_free((struct shape_global*)s);
      break;
    case BLOCK:
      shape_block_free((struct shape_block*)s);
      break;
    case ABSBLOCK:
      shape_block_free((struct shape_block*)s);
      break;
    default:
      fprintf(stderr, "kdotp::libmodelxx::grid::shape_free: didn't recognize non-generic shape type (numeric %d)\n", s->type);
    }
  }
  free(s);
      }

Here is the call graph for this function:

Here is the caller graph for this function:

void kdotp::libmodelxx::grid::shape_global_free ( struct shape_global *  b)

Definition at line 164 of file shapes.c++.

Referenced by shape_free().

                                                     {
  free(b);
      }

Here is the caller graph for this function:

void kdotp::libmodelxx::grid::shape_tree_free ( struct shape_tree *  st)

Definition at line 193 of file shapes.c++.

References kdotp::libmodelxx::grid::shape_tree::l, LEAF, kdotp::libmodelxx::grid::shape_tree::op, kdotp::libmodelxx::grid::shape_tree::r, and shape_free().

Referenced by key_value_free().

                                                  {
  if(st == NULL) return;
  if(st->op != LEAF) {
    shape_tree_free(st->l);
    shape_tree_free(st->r);
  }else{
    shape_free((struct shape*)st);
  }
      }

Here is the call graph for this function:

Here is the caller graph for this function:

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines