• Main Page
  • Classes
  • Files
  • File List
  • File Members

microphysics/integrate_diffusion.c

Go to the documentation of this file.
00001 #include "../copyright.h"
00002 /*============================================================================*/
00003 /*! \file integrate_diffusion.c
00004  *  \brief Contains public functions to integrate explicit diffusion terms
00005  *   using operator splitting.
00006  *
00007  * CONTAINS PUBLIC FUNCTIONS: 
00008  * - integrate_diff() - calls functions for each diffusion operator
00009  * - integrate_diff_init() - allocates memory for diff functions
00010  * - integrate_diff_destruct() - frees memory for diff functions */
00011 /*============================================================================*/
00012 
00013 #include <stdio.h>
00014 #include <stdlib.h>
00015 #include "../defs.h"
00016 #include "../athena.h"
00017 #include "../globals.h"
00018 #include "../prototypes.h"
00019 #include "prototypes.h"
00020 
00021 /*----------------------------------------------------------------------------*/
00022 /*! \fn void integrate_diff(MeshS *pM)
00023  *  \brief Called in main loop, sets timestep and/or orchestrates
00024  * subcycling, calls appropriate functions for each diffusion operator
00025  */
00026 
00027 void integrate_diff(MeshS *pM)
00028 {
00029   GridS *pG;
00030   int nl,nd;
00031   Real dtmin_expl;
00032 
00033 /* Calculate the magnetic diffusivity array
00034  */
00035 #ifdef RESISTIVITY
00036   for (nl=0; nl<(pM->NLevels); nl++){
00037     for (nd=0; nd<(pM->DomainsPerLevel[nl]); nd++){
00038       if (pM->Domain[nl][nd].Grid != NULL) {
00039 
00040         pG=pM->Domain[nl][nd].Grid;
00041 
00042         get_eta(pG);
00043       }
00044     }
00045   }
00046 #endif
00047 
00048   dtmin_expl = diff_dt(pM);
00049 
00050 /* Limit timestep by minimum for explicit update of diffusion operators.
00051  * Currently, subcycling is not implemented!! */
00052 
00053   pM->dt = MIN(pM->dt, dtmin_expl);;
00054 
00055   for (nl=0; nl<(pM->NLevels); nl++){
00056     for (nd=0; nd<(pM->DomainsPerLevel[nl]); nd++){
00057       if (pM->Domain[nl][nd].Grid != NULL) {
00058         pG=pM->Domain[nl][nd].Grid;
00059         pG->dt = pM->dt;
00060 
00061 /* Call diffusion operators across Mesh hierarchy.
00062  * Conduction must be called first to avoid an extra call to bval_mhd().  */
00063 
00064 #ifdef THERMAL_CONDUCTION
00065         conduction(&(pM->Domain[nl][nd]));
00066 #endif
00067 
00068 #ifdef RESISTIVITY
00069         resistivity(&(pM->Domain[nl][nd]));
00070 #endif
00071 
00072 #ifdef VISCOSITY
00073         viscosity(&(pM->Domain[nl][nd]));
00074 #endif
00075       }
00076     }
00077   }
00078 
00079   return;
00080 }
00081 
00082 /*----------------------------------------------------------------------------*/
00083 /*! \fn void integrate_diff_init(MeshS *pM)
00084  *  \brief Call functions to allocate memory
00085  */
00086 
00087 void integrate_diff_init(MeshS *pM)
00088 {   
00089 /* Check that diffusion coefficients were set in problem generator, call memory
00090  * allocation routines.  */
00091 
00092 #ifdef THERMAL_CONDUCTION
00093   if ((kappa_iso + kappa_aniso) <= 0.0) 
00094     ath_error("[diff_init] coefficents of thermal conduction not set\n");
00095   conduction_init(pM);
00096 #endif
00097 
00098 #ifdef VISCOSITY
00099   if ((nu_iso + nu_aniso) <= 0.0) 
00100     ath_error("[diff_init] coefficents of viscosity not set\n");
00101   viscosity_init(pM);
00102 #endif
00103 
00104 #ifdef RESISTIVITY
00105   if ((eta_Ohm + Q_Hall + Q_AD) <= 0.0) 
00106     ath_error("[diff_init] coefficents of resistivity not set\n");
00107   resistivity_init(pM);
00108 #endif
00109 
00110   return;
00111 }
00112 
00113 /*----------------------------------------------------------------------------*/
00114 /*! \fn void integrate_diff_destruct()
00115  *  \brief Frees memory associated with diffusion funcs  */
00116 void integrate_diff_destruct()
00117 {
00118 #ifdef THERMAL_CONDUCTION
00119   conduction_destruct();
00120 #endif
00121 #ifdef RESISTIVTY
00122   resistivity_destruct();
00123 #endif
00124 #ifdef VISCOSITY
00125   viscosity_destruct();
00126 #endif
00127 }

Generated on Mon Sep 27 2010 23:03:07 for Athena by  doxygen 1.7.1