Streamer fluid modeling - An overview of ARCoS  1.0
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Macros | Functions | Variables
cdr.c File Reference

Routines for handling the CDR (convection-diffusion-reaction) equations. More...

#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <sys/time.h>
#include "cdr.h"
#include "cstream.h"
#include "grid.h"
#include "interpol2.h"
#include "mapper.h"
#include "parameters.h"
#include "poisson.h"
#include "proto.h"
#include "react_table.h"
#include "rz_array.h"
#include "species.h"
#include "tree.h"
Include dependency graph for cdr.c:

Go to the source code of this file.

Macros

#define pij(p_, stride_)   (((*(p_)) - *((p_) - (stride_))) / (*((p_) + (stride_)) - *(p_)))
 This thing looks really ugly, but what does it mean? For example, for stride = dens[electrons]->strides[R_INDX], it is the $p_{ij}$ of the aforementioned paper: $p_{i,j} = (\sigma_{i,j} - \sigma_{i-1,j}) / (\sigma_{i+1,j} - \sigma_{i,j})$.
 

Functions

 decl_mapper_funcs (dens)
 
static void set_all_bnd (cdr_grid_t *grid, int sign, int ir, int iz, int itheta, int dim0, int inout, int dim1, int dim1_from, int dim1_to, int dim2, int dim2_from, int dim2_to)
 
static void set_axis_bnd (cdr_grid_t *grid)
 Sets the proper boundary conditions for a grid that has its left boundary at r = 0 (e.g. the root grid).
 
static void max_update (double *x, double cmp)
 
static double f_ad (rz_array_t *dens, double efield, double dc, double mc, int ir, int iz, int itheta, int dim)
 This is the F^a + F^d in the paper (times $\delta${r, z, $\theta$}).
 
static double psi (double theta)
 
static void prepare_grid (cdr_grid_t *grid)
 Prepares a grid family : a) Set the boundaries for all subgrids,
b) Restrict the coarser grids from the fine ones.
.
 
static double curv_at (cdr_grid_t *grid, rz_array_t *ar, int ir, int iz, int itheta, double(*f)(double))
 Determines the curvature of ar, which has to be a component of grid at ir, iz.
 
static int needs_refinement (cdr_grid_t *grid, int ir, int iz, int itheta, int *in_edge)
 Does the point in grid at ir, iz, itheta require to be further refined?
 
static int any_needs_refinement (cdr_grid_t *grid, int ir, int iz, int *in_edge)
 Calls the needs_refinement at all $\theta$ and returns true if the grids needs to be refined in any of the angles.
 
static int brick_needs_refinement (cdr_grid_t *grid, int r0, int z0, int r1, int z1, int *in_edge)
 Determines whether a brick needs refinement.
 
static void refine_in (cdr_grid_t *grid, int cr0, int cz0, int cr1, int cz1, int contains_edge)
 Adds a child to a cdr grid.
 
static void restrict_from (cdr_grid_t *parent, cdr_grid_t *child)
 Restricts the values of the densities from the child grid into the parent.
 
static int match_grids (cdr_grid_t *fro, cdr_grid_t *to)
 Matches the boundaries of grid to reading from grid fro.
 
double gauss2_xyz (double x, double y, double z)
 
void aux_dump_frames_r (cdr_grid_t *grid, FILE *fp)
 aux_dump_frames_r QQQQ
 
void cdr_init (void)
 Some initialization is needed for this module which has to be inside this function.
 
void cdr_end (void)
 And the cleaning up has to be here.
 
cdr_grid_tcdr_new_3d_a (int r0, int z0, int r1, int z1, int ntheta)
 Creates a new 3D cdr grid.
 
cdr_grid_tcdr_guest (cdr_grid_t *host, int r0, int z0, int r1, int z1)
 Creates a guest cdr grid:
 
cdr_grid_tcdr_like_a (cdr_grid_t *grid)
 Returns a grid with the same dimensions as grid and at the same level.
 
cdr_grid_tcdr_clone_a (cdr_grid_t *grid)
 Returns a grid exactly like te one received, with the densities copied.
 
void cdr_set_periodic (cdr_grid_t *grid)
 Impose periodic boundary conditions in $\theta$ on a grid.
 
 mk_recursive (cdr_set_periodic, cdr_grid_t)
 Recursive version of cdr_set_periodic.
 
void cdr_free_r (cdr_grid_t *grid)
 Recursive version of cdr_free.
 
void cdr_calc_charge (cdr_grid_t *grid)
 Calculates the charge in a CDR grid.
 
 mk_recursive (cdr_calc_charge, cdr_grid_t)
 Recursive version of cdr_calc_charge.
 
void cdr_dft_field_r (cdr_grid_t *grid, int sign)
 Fourier-transforms the electric field in grid and all its descendants.
 
cdr_grid_tcdr_create_coarser_a (cdr_grid_t *grid)
 Creates a grid one level coarser than GRID that covers the same area or somewhat more.
 
cdr_grid_tcdr_add_coarser_grids_a (cdr_grid_t *prev_root, int n)
 Takes a tree of input nodes and adds n coarser grids, returning a pointer to the root leaf.
 
void cdr_free_coarser_grids (cdr_grid_t *prev_root, int n)
 Frees the memory allocated by cdr_add_coarser_grids_a.
 
pois_grid_t ** cdr_calc_field_r (cdr_grid_t *cdr, int return_pois)
 The interface between the cdr and the poisson parts.
 
void cdr_add_ext_field (cdr_grid_t *grid)
 Adds an external electric field to a cdr grid.
 
 mk_recursive (cdr_add_ext_field, cdr_grid_t)
 Recursive version of cdr_add_ext_field.
 
void cdr_calc_eabs (cdr_grid_t *grid)
 Calculates the absolute value of the electric field by linear interpolation of its components.
 
 mk_recursive (cdr_calc_eabs, cdr_grid_t)
 Recursive version of cdr_calc_eabs.
 
 mk_recursive (cdr_nonegative, cdr_grid_t)
 Recursive version of cdr_nonegative.
 
 mk_recursive (cdr_set_ext_bnd, cdr_grid_t)
 Recursive version of cdr_set_ext_bnd.
 
void cdr_calc_d_dens (cdr_grid_t *grid)
 Calculates the derivatives of the densities for each point of the grid.
 
void cdr_advect_diffu (cdr_grid_t *grid)
 Adds the advection and diffusion terms to the derivatives of the densities.
 
 mk_recursive (cdr_advect_diffu, cdr_grid_t)
 Limiter function, psi( $\theta$) = max (0, min(1, 1/3 + $\theta$/6, $\theta$))
 
double cdr_courant (cdr_grid_t *grid)
 Returns the minimum tau that satisfies the Courant-Friedrichs-Lewy restriction (CFL).
 
void cdr_update (cdr_grid_t *orig, cdr_grid_t *dest, double h)
 Writes into the densities of the grid dest the densities of grid orig plus its derivatives times h.
 
void cdr_rk2_update (cdr_grid_t *dens_0, cdr_grid_t *d_dens_1, cdr_grid_t *d_dens_2, cdr_grid_t *dest, double h)
 Sets dest->dens = dens_0->dens + h/2 * d_dens_1->d_dens +
h/2 * d_dens_2->d_dens.
 
void cdr_rk2_update_r (cdr_grid_t *dens_0, cdr_grid_t *d_dens_1, cdr_grid_t *d_dens_2, cdr_grid_t *dest, double h)
 Recursive version of cdr_rk2_update.
 
void cdr_self_update_r (cdr_grid_t *grid, double h)
 Recursive version of the former QQQQ, used to implement Euler integration.
 
void cdr_like_update_ar (cdr_grid_t *grid, cdr_grid_t *new_grid, double h)
 Yet another recursive version of cdr_update, used to implement higher order Runge-Kutta integrations.
 
double cdr_rk2 (cdr_grid_t *grid, double h, double t)
 Computes the grid error. QQQQ.
 
void cdr_update_refined (cdr_grid_t **ptree)
 Takes a pointer to a family of cdr grids, creates a new family which is stored in that pointer and takes rid of the initial family.
 
void cdr_calc_maxs (cdr_grid_t *grid)
 Updates the values of max_dens and max_charge.
 
void cdr_refine (cdr_grid_t *grid)
 Uses the previous routines to refine (if needed) a cdr grid.
 
void cdr_refine_r (cdr_grid_t *grid, cdr_grid_t *source)
 Recursively refines a cdr grid and constructs a tree based on it.
 
void cdr_match_r (cdr_grid_t *grid1, cdr_grid_t *grid2)
 Examines pairs of grids and matches them and all their descendants.
 
void cdr_set_bnd (cdr_grid_t *grid)
 Sets the boundary conditions of all children of grid by interpolating from grid itself.
 
 mk_recursive (cdr_set_bnd, cdr_grid_t)
 Recursive version of cdr_set_bnd.
 
void cdr_free_mappers (mapper_t **mappers)
 Frees the memory of all mappers QQQQ.
 
void dens_copy (mapper_t *mapper, grid_t *source, grid_t *target, int ir, int iz, int itheta)
 dens_copy Copies QQQQ
 
int dens_interpol_set (mapper_t *mapper, grid_t *source, interpol_t *interpol, int pr, int pz, int itheta)
 Interpolates a set QQQQ.
 
void dens_interpol (mapper_t *mapper, grid_t *source, grid_t *target, interpol_t *interpol, int ir, int iz, int itheta)
 dens_interpol Interpolates QQQQ
 
void cdr_restrict (cdr_grid_t *grid)
 Restricts a grid with all its children.
 
 mk_tail_recursive (cdr_restrict, cdr_grid_t)
 And its recursive version.
 
void cdr_set_dens (cdr_grid_t *cdr, int species, int mode, double factor, double(*f)(double, double, double))
 Sets the densities of species species according to the function $f (x, y, z)$.
 
double f_one (double x, double y, double z)
 Returns 1.0.
 
void cdr_init_dens (cdr_grid_t *cdr)
 Inits the densities of all species.
 
cdr_grid_tcdr_scratch_init (void)
 Initializes the densities allocating a new grid family.
 
void cdr_dump (cdr_grid_t *grid, const char *prefix, const char *name)
 Dumps all the contents of the given grid into filenames given by prefix and name.
 
void cdr_dump_r (cdr_grid_t *grid, const char *prefix, const char *name, FILE *infp, double sim_time)
 Dumps all the contents of the given grid into filenames given by prefix and name.
 
cdr_grid_tcdr_load_tree_r (const char *prefix, const char *name, FILE *infp)
 Reads the data format produced by cdr_dump_r and creates a complete tree from it.
 
void cdr_dump_frames (cdr_grid_t *grid, const char *prefix, const char *name)
 Given a grid family, writes in the file named fname the coordinates of the frames that define the grid and his descendants.
 

Variables

mapper_t ** dens_mappers
 
mapper_t ** dens_bnd_mappers
 
int cdr_ext_bnd_cond [4]
 
double z_cutoff = 10000000.0
 
double max_err = 0.0
 
react_table mu
 
react_table diff
 
pois_problem_tpois_electrostatic
 
int curr_seed = 0
 

Detailed Description

Routines for handling the CDR (convection-diffusion-reaction) equations.

Default interpolation methods.
May be changed elsewhere.

interpol_method_t *cdr_interpol_inside = &interpol_quadratic;
interpol_method_t *cdr_interpol_bnd = &interpol_bilin;

Definition in file cdr.c.

Macro Definition Documentation

#define pij (   p_,
  stride_ 
)    (((*(p_)) - *((p_) - (stride_))) / (*((p_) + (stride_)) - *(p_)))

This thing looks really ugly, but what does it mean? For example, for stride = dens[electrons]->strides[R_INDX], it is the $p_{ij}$ of the aforementioned paper: $p_{i,j} = (\sigma_{i,j} - \sigma_{i-1,j}) / (\sigma_{i+1,j} - \sigma_{i,j})$.

Definition at line 847 of file cdr.c.

Function Documentation

decl_mapper_funcs ( dens  )

Declaration of the functions to interpolate the densities.

static void set_all_bnd ( cdr_grid_t grid,
int  sign,
int  ir,
int  iz,
int  itheta,
int  dim0,
int  inout,
int  dim1,
int  dim1_from,
int  dim1_to,
int  dim2,
int  dim2_from,
int  dim2_to 
)
static

Here is the caller graph for this function:

static void set_axis_bnd ( cdr_grid_t grid)
static

Sets the proper boundary conditions for a grid that has its left boundary at r = 0 (e.g. the root grid).

We don't set Hom. Neumann at r = r0 since r = r0 is not a real boundary: the proper condition here is matching the opposite grid. But note that this condition reduces to Hom. Neumann in the case ntheta = 1 (because itheta2 = itheta = 0).

Definition at line 798 of file cdr.c.

Here is the call graph for this function:

Here is the caller graph for this function:

static void max_update ( double *  x,
double  cmp 
)
static

Definition at line 1064 of file cdr.c.

Here is the caller graph for this function:

static double f_ad ( rz_array_t dens,
double  efield,
double  dc,
double  mc,
int  ir,
int  iz,
int  itheta,
int  dim 
)
static

This is the F^a + F^d in the paper (times $\delta${r, z, $\theta$}).

Definition at line 852 of file cdr.c.

Here is the call graph for this function:

static double psi ( double  theta)
static

Here is the caller graph for this function:

static void prepare_grid ( cdr_grid_t grid)
static

Prepares a grid family : a) Set the boundaries for all subgrids,
b) Restrict the coarser grids from the fine ones.
.

Definition at line 1334 of file cdr.c.

Here is the call graph for this function:

Here is the caller graph for this function:

static double curv_at ( cdr_grid_t grid,
rz_array_t ar,
int  ir,
int  iz,
int  itheta,
double(*)(double)  f 
)
static

Determines the curvature of ar, which has to be a component of grid at ir, iz.

If f is nonnull, determines the curvature of $f(ar)$.
Note that we only consider the curvatures in r and z (not in $\theta$). This is because $\theta$ is never refined. (can that be changed in some future?)

Definition at line 1429 of file cdr.c.

Here is the caller graph for this function:

static int needs_refinement ( cdr_grid_t grid,
int  ir,
int  iz,
int  itheta,
int *  in_edge 
)
static

Does the point in grid at ir, iz, itheta require to be further refined?

Definition at line 1461 of file cdr.c.

Here is the call graph for this function:

Here is the caller graph for this function:

static int any_needs_refinement ( cdr_grid_t grid,
int  ir,
int  iz,
int *  in_edge 
)
static

Calls the needs_refinement at all $\theta$ and returns true if the grids needs to be refined in any of the angles.

This is the safest thing to do, but some other criterium could be imagined as well. The search is stopped as soon as a cell that requires refinement is found, but not if it requires refinement due to the leading edge density criterium. This is because we need to find where we have to stop applying that criterium.

Definition at line 1582 of file cdr.c.

Here is the call graph for this function:

Here is the caller graph for this function:

static int brick_needs_refinement ( cdr_grid_t grid,
int  r0,
int  z0,
int  r1,
int  z1,
int *  in_edge 
)
static

Determines whether a brick needs refinement.

Now we look if we need refinement in a brick
i.e. a rectangle in r, z space (usually, height = cdr_brick_dz, width = cdr_brick_dr), but can be smaller if we reach a boundary.

See above, any_needs_refinement to see when do we stop the search.

Definition at line 1609 of file cdr.c.

Here is the call graph for this function:

Here is the caller graph for this function:

static void refine_in ( cdr_grid_t grid,
int  cr0,
int  cz0,
int  cr1,
int  cz1,
int  contains_edge 
)
static

Adds a child to a cdr grid.

The coordinates are in the parent's units

Definition at line 1689 of file cdr.c.

Here is the call graph for this function:

Here is the caller graph for this function:

static void restrict_from ( cdr_grid_t parent,
cdr_grid_t child 
)
static

Restricts the values of the densities from the child grid into the parent.

Definition at line 2050 of file cdr.c.

Here is the caller graph for this function:

static int match_grids ( cdr_grid_t fro,
cdr_grid_t to 
)
static

Matches the boundaries of grid to reading from grid fro.

Returns TRUE if there was a matching, FALSE otherwise. Maybe this function should be rewritten to make it more compact and clear.

Definition at line 1808 of file cdr.c.

Here is the call graph for this function:

Here is the caller graph for this function:

double gauss2_xyz ( double  x,
double  y,
double  z 
)

Here is the caller graph for this function:

void aux_dump_frames_r ( cdr_grid_t grid,
FILE *  fp 
)

aux_dump_frames_r QQQQ

Definition at line 2531 of file cdr.c.

Here is the caller graph for this function:

void cdr_init ( void  )

Some initialization is needed for this module which has to be inside this function.

Definition at line 80 of file cdr.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void cdr_end ( void  )

And the cleaning up has to be here.

Definition at line 95 of file cdr.c.

Here is the call graph for this function:

Here is the caller graph for this function:

cdr_grid_t* cdr_new_3d_a ( int  r0,
int  z0,
int  r1,
int  z1,
int  ntheta 
)

Creates a new 3D cdr grid.

Definition at line 103 of file cdr.c.

Here is the call graph for this function:

Here is the caller graph for this function:

cdr_grid_t* cdr_guest ( cdr_grid_t host,
int  r0,
int  z0,
int  r1,
int  z1 
)

Creates a guest cdr grid:

one that does not have memory of its own but points to the data of another grid (the host grid). This is useful to easily set boundary conditions. Probably, this function and cdr_new_3d_a should be somehow merged.

Definition at line 170 of file cdr.c.

Here is the call graph for this function:

Here is the caller graph for this function:

cdr_grid_t* cdr_like_a ( cdr_grid_t grid)

Returns a grid with the same dimensions as grid and at the same level.

Realize that the data is not copied into the new grid.

Definition at line 234 of file cdr.c.

Here is the call graph for this function:

Here is the caller graph for this function:

cdr_grid_t* cdr_clone_a ( cdr_grid_t grid)

Returns a grid exactly like te one received, with the densities copied.

But the descendants are ignored.

Definition at line 255 of file cdr.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void cdr_set_periodic ( cdr_grid_t grid)

Impose periodic boundary conditions in $\theta$ on a grid.

Definition at line 288 of file cdr.c.

Here is the call graph for this function:

mk_recursive ( cdr_set_periodic  ,
cdr_grid_t   
)

Recursive version of cdr_set_periodic.

Frees a cdr grid.

Definition at line 310 of file cdr.c.

Here is the call graph for this function:

void cdr_free_r ( cdr_grid_t grid)

Recursive version of cdr_free.

Definition at line 341 of file cdr.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void cdr_calc_charge ( cdr_grid_t grid)

Calculates the charge in a CDR grid.

Important Note: The charge is here divided by ntheta because our FFT functions are unnormalized and hence when they are applied forth and back they return the initial value multiplied by ntheta. I believe that this is the best point to normalize the data.

Definition at line 361 of file cdr.c.

Here is the call graph for this function:

Here is the caller graph for this function:

mk_recursive ( cdr_calc_charge  ,
cdr_grid_t   
)

Recursive version of cdr_calc_charge.

Definition at line 389 of file cdr.c.

Here is the call graph for this function:

void cdr_dft_field_r ( cdr_grid_t grid,
int  sign 
)

Fourier-transforms the electric field in grid and all its descendants.

Definition at line 409 of file cdr.c.

Here is the call graph for this function:

Here is the caller graph for this function:

cdr_grid_t* cdr_create_coarser_a ( cdr_grid_t grid)

Creates a grid one level coarser than GRID that covers the same area or somewhat more.

Note: The new grid contains information only about the charge, not the other functions. That's why we don't use cdr_restrict.

Note that here we may be going one cell out of the aparent boundaries of the input grids but we allocated enough memory for that.

Definition at line 435 of file cdr.c.

Here is the call graph for this function:

Here is the caller graph for this function:

cdr_grid_t* cdr_add_coarser_grids_a ( cdr_grid_t prev_root,
int  n 
)

Takes a tree of input nodes and adds n coarser grids, returning a pointer to the root leaf.

Definition at line 480 of file cdr.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void cdr_free_coarser_grids ( cdr_grid_t prev_root,
int  n 
)

Frees the memory allocated by cdr_add_coarser_grids_a.

Note: be careful to pass here only a tree returned by cdr_add_coarser_grids_a, since some grids may lose their references and stay allocated forever otherwise. (see assert below).

Definition at line 508 of file cdr.c.

Here is the call graph for this function:

Here is the caller graph for this function:

pois_grid_t** cdr_calc_field_r ( cdr_grid_t cdr,
int  return_pois 
)

The interface between the cdr and the poisson parts.

If return_pois is true, returns the Poisson trees and they have to be de-allocated by the calling program. If not, takes care himself of deallocation and returns NULL.

Definition at line 532 of file cdr.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void cdr_add_ext_field ( cdr_grid_t grid)

Adds an external electric field to a cdr grid.

Really, it would be more efficient to include that field in some other routine and we will avoid one more grid sweep. However, for the sake of code clarity, extendability and maintenability I prefer to add it here.

ext_e_r, ext_e_z and ext_e_theta are functions of three real numbers (r, z, $\theta$) that return each of the components of the electric field.

Note that it is the responsibility of e_theta to behave correctly (i.e. periodically) when it receives thetas outside $[0, 2 \pi]$.

Definition at line 595 of file cdr.c.

mk_recursive ( cdr_add_ext_field  ,
cdr_grid_t   
)

Recursive version of cdr_add_ext_field.

Definition at line 625 of file cdr.c.

Here is the call graph for this function:

void cdr_calc_eabs ( cdr_grid_t grid)

Calculates the absolute value of the electric field by linear interpolation of its components.

Of course, it requires that all the components are already present.

Definition at line 668 of file cdr.c.

mk_recursive ( cdr_calc_eabs  ,
cdr_grid_t   
)

Recursive version of cdr_calc_eabs.

Makes sure that all species of one grid are non-negative.

Definition at line 695 of file cdr.c.

mk_recursive ( cdr_nonegative  ,
cdr_grid_t   
)

Recursive version of cdr_nonegative.

Sets the boundary values for the root grid and those grids that have a boundary coinciding with any of the boundaries of the root grid.

Definition at line 721 of file cdr.c.

Here is the call graph for this function:

mk_recursive ( cdr_set_ext_bnd  ,
cdr_grid_t   
)

Recursive version of cdr_set_ext_bnd.

Definition at line 768 of file cdr.c.

Here is the call graph for this function:

void cdr_calc_d_dens ( cdr_grid_t grid)

Calculates the derivatives of the densities for each point of the grid.

Definition at line 830 of file cdr.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void cdr_advect_diffu ( cdr_grid_t grid)

Adds the advection and diffusion terms to the derivatives of the densities.

Definition at line 900 of file cdr.c.

Here is the call graph for this function:

mk_recursive ( cdr_advect_diffu  ,
cdr_grid_t   
)

Limiter function, psi( $\theta$) = max (0, min(1, 1/3 + $\theta$/6, $\theta$))

Definition at line 955 of file cdr.c.

double cdr_courant ( cdr_grid_t grid)

Returns the minimum tau that satisfies the Courant-Friedrichs-Lewy restriction (CFL).

Definition at line 971 of file cdr.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void cdr_update ( cdr_grid_t orig,
cdr_grid_t dest,
double  h 
)

Writes into the densities of the grid dest the densities of grid orig plus its derivatives times h.

If orig = dest, this implements an Euler step. But it can also be used as a tool to implement a RK

Definition at line 1075 of file cdr.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void cdr_rk2_update ( cdr_grid_t dens_0,
cdr_grid_t d_dens_1,
cdr_grid_t d_dens_2,
cdr_grid_t dest,
double  h 
)

Sets dest->dens = dens_0->dens + h/2 * d_dens_1->d_dens +
h/2 * d_dens_2->d_dens.

Useful to implement 2nd order RK time-stepping.

Definition at line 1107 of file cdr.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void cdr_rk2_update_r ( cdr_grid_t dens_0,
cdr_grid_t d_dens_1,
cdr_grid_t d_dens_2,
cdr_grid_t dest,
double  h 
)

Recursive version of cdr_rk2_update.

Note: we assume here that all the trees are congruent: this is, they have the same structure with nodes of the same size.

Definition at line 1143 of file cdr.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void cdr_self_update_r ( cdr_grid_t grid,
double  h 
)

Recursive version of the former QQQQ, used to implement Euler integration.

Definition at line 1168 of file cdr.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void cdr_like_update_ar ( cdr_grid_t grid,
cdr_grid_t new_grid,
double  h 
)

Yet another recursive version of cdr_update, used to implement higher order Runge-Kutta integrations.

It creates a new tree of cdr grids.

Definition at line 1184 of file cdr.c.

Here is the call graph for this function:

Here is the caller graph for this function:

double cdr_rk2 ( cdr_grid_t grid,
double  h,
double  t 
)

Computes the grid error. QQQQ.

Recursive version of cdr_grid_error. QQQQ Makes a full second order Runge-Kutta step.

Returns the timestep actually performed, which can be smaller that h if it does not satisfy the Courant criterium.

Definition at line 1262 of file cdr.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void cdr_update_refined ( cdr_grid_t **  ptree)

Takes a pointer to a family of cdr grids, creates a new family which is stored in that pointer and takes rid of the initial family.

This function is the entry point of the refinement code.

Definition at line 1363 of file cdr.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void cdr_calc_maxs ( cdr_grid_t grid)

Updates the values of max_dens and max_charge.

This values are needed for the refinement criterium.

Definition at line 1383 of file cdr.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void cdr_refine ( cdr_grid_t grid)

Uses the previous routines to refine (if needed) a cdr grid.

Definition at line 1626 of file cdr.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void cdr_refine_r ( cdr_grid_t grid,
cdr_grid_t source 
)

Recursively refines a cdr grid and constructs a tree based on it.

if source == NULL
then uses the initial densities
else sets the densities of the newly created grids by interpolating and copying from the tree source.

Definition at line 1720 of file cdr.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void cdr_match_r ( cdr_grid_t grid1,
cdr_grid_t grid2 
)

Examines pairs of grids and matches them and all their descendants.

If grid2 == NULL, matches only the descendats of grid1. Hence, this routine is usually called as cdr_match_r (root, NULL).

Definition at line 1763 of file cdr.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void cdr_set_bnd ( cdr_grid_t grid)

Sets the boundary conditions of all children of grid by interpolating from grid itself.

Definition at line 1888 of file cdr.c.

Here is the call graph for this function:

mk_recursive ( cdr_set_bnd  ,
cdr_grid_t   
)

Recursive version of cdr_set_bnd.

Mapping of the densities.

Definition at line 1948 of file cdr.c.

Here is the call graph for this function:

void cdr_free_mappers ( mapper_t **  mappers)

Frees the memory of all mappers QQQQ.

Definition at line 1988 of file cdr.c.

Here is the caller graph for this function:

void dens_copy ( mapper_t mapper,
grid_t source,
grid_t target,
int  ir,
int  iz,
int  itheta 
)

dens_copy Copies QQQQ

Definition at line 2000 of file cdr.c.

Here is the caller graph for this function:

int dens_interpol_set ( mapper_t mapper,
grid_t source,
interpol_t interpol,
int  pr,
int  pz,
int  itheta 
)

Interpolates a set QQQQ.

Definition at line 2014 of file cdr.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void dens_interpol ( mapper_t mapper,
grid_t source,
grid_t target,
interpol_t interpol,
int  ir,
int  iz,
int  itheta 
)

dens_interpol Interpolates QQQQ

Definition at line 2030 of file cdr.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void cdr_restrict ( cdr_grid_t grid)

Restricts a grid with all its children.

Definition at line 2083 of file cdr.c.

Here is the call graph for this function:

mk_tail_recursive ( cdr_restrict  ,
cdr_grid_t   
)

And its recursive version.

Note that this has to be tail recursive, sice we first have to restrict the childs.

Definition at line 2097 of file cdr.c.

void cdr_set_dens ( cdr_grid_t cdr,
int  species,
int  mode,
double  factor,
double(*)(double, double, double)  f 
)

Sets the densities of species species according to the function $f (x, y, z)$.

mode can be one of the following:
SET_DENS_OVERWRITE: Set the dens to f(x, y, x), ignoring what was there before.
SET_DENS_ADD: Adds f to the former density.
SET_DENS_SUB: Substracts f from the former density.

Definition at line 2126 of file cdr.c.

Here is the caller graph for this function:

double f_one ( double  x,
double  y,
double  z 
)

Returns 1.0.

Definition at line 2166 of file cdr.c.

Here is the caller graph for this function:

void cdr_init_dens ( cdr_grid_t cdr)

Inits the densities of all species.

Definition at line 2173 of file cdr.c.

Here is the call graph for this function:

Here is the caller graph for this function:

cdr_grid_t* cdr_scratch_init ( void  )

Initializes the densities allocating a new grid family.

Definition at line 2197 of file cdr.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void cdr_dump ( cdr_grid_t grid,
const char *  prefix,
const char *  name 
)

Dumps all the contents of the given grid into filenames given by prefix and name.

Definition at line 2226 of file cdr.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void cdr_dump_r ( cdr_grid_t grid,
const char *  prefix,
const char *  name,
FILE *  infp,
double  sim_time 
)

Dumps all the contents of the given grid into filenames given by prefix and name.

It also writes in tree.NAME.dat the tree structure of grid, in a format appropiate for cdr_load_tree to understand.

infp has to be NULL when called from outside.

The format of a tree.NAME.dat is as follows. Each line is composed by a "command" and some parameters. the "commands" can be

time parameter: sim_time Writes the current simulation time, as received in sim_time

open parameters: gridname r0 z0 r1 z1 level ext_bound margin

Reads the densities from the files given by gridname, with the corresponding values of the grid parameters. Leaves the grid open to add childrens to it. Those children will be all the grids read until the grid is closed.

close parameters: gridname

Closes the latest opened grid. All subsequent grids will be regarded as brothers of gridname.

Definition at line 2360 of file cdr.c.

Here is the call graph for this function:

Here is the caller graph for this function:

cdr_grid_t* cdr_load_tree_r ( const char *  prefix,
const char *  name,
FILE *  infp 
)

Reads the data format produced by cdr_dump_r and creates a complete tree from it.

This function is really quick-and-dirty: one should check the fscanfs and do everything cleanlier.

Definition at line 2425 of file cdr.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void cdr_dump_frames ( cdr_grid_t grid,
const char *  prefix,
const char *  name 
)

Given a grid family, writes in the file named fname the coordinates of the frames that define the grid and his descendants.

Definition at line 2511 of file cdr.c.

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

mapper_t** dens_mappers

Definition at line 33 of file cdr.c.

mapper_t ** dens_bnd_mappers

Definition at line 33 of file cdr.c.

int cdr_ext_bnd_cond[4]

Definition at line 35 of file cdr.c.

double z_cutoff = 10000000.0

Definition at line 36 of file cdr.c.

double max_err = 0.0

Definition at line 37 of file cdr.c.

Definition at line 38 of file cdr.c.

Definition at line 39 of file cdr.c.

pois_problem_t* pois_electrostatic

Definition at line 82 of file poisson.c.

int curr_seed = 0

Definition at line 70 of file cdr.c.