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

prob/current_sheet.c

Go to the documentation of this file.
00001 #include "copyright.h"
00002 /*============================================================================*/
00003 /*! \file current_sheet.c
00004  *  \brief Problem generator for current sheet test. 
00005  *
00006  * PURPOSE: Problem generator for current sheet test.  This version only allows
00007  *   current sheet in X-Y plane, with Bz=0.  
00008  *
00009  * REFERENCE: */
00010 /*============================================================================*/
00011 
00012 #include <math.h>
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 
00020 #ifdef HYDRO
00021 #error : The current sheet test only works for MHD.
00022 #endif /* HYDRO */
00023 
00024 /*----------------------------------------------------------------------------*/
00025 /* problem:  */
00026 
00027 void problem(DomainS *pDomain)
00028 {
00029   GridS *pGrid=(pDomain->Grid);
00030   Prim1DS W;
00031   Cons1DS U1d;
00032   int i, is = pGrid->is, ie = pGrid->ie;
00033   int j, js = pGrid->js, je = pGrid->je;
00034   int k, ks = pGrid->ks, ke = pGrid->ke;
00035   Real x1,x2,x3;
00036   Real Bx,uflow,beta;
00037 
00038 /* setup uniform ambient medium with current sheet */
00039 
00040   uflow = par_getd("problem","uflow");
00041   beta  = par_getd("problem","beta");
00042   W.d = 1.0;
00043   W.P = beta;
00044   W.Vy = 0.0;
00045   W.Vz = 0.0;
00046   Bx = 0.0;
00047   W.By = 1.0;
00048   W.Bz = 0.0;
00049   for (k=ks; k<=ke; k++) {
00050     for (j=js; j<=je; j++) {
00051       for (i=is; i<=ie; i++) {
00052         cc_pos(pGrid,i,j,k,&x1,&x2,&x3);
00053         W.Vx = uflow*cos(PI*x2);
00054         U1d = Prim1D_to_Cons1D(&(W), &Bx);
00055         pGrid->U[k][j][i].d  = U1d.d;
00056         pGrid->U[k][j][i].M1 = U1d.Mx; 
00057         pGrid->U[k][j][i].M2 = U1d.My;
00058         pGrid->U[k][j][i].M3 = U1d.Mz;
00059 #ifndef ISOTHERMAL
00060         pGrid->U[k][j][i].E = U1d.E;
00061 #endif
00062         pGrid->U[k][j][i].B1c = Bx;
00063         pGrid->U[k][j][i].B2c = U1d.By;
00064         pGrid->U[k][j][i].B3c = U1d.Bz;
00065         pGrid->B1i[k][j][i] = Bx;
00066         pGrid->B2i[k][j][i] = U1d.By;
00067         pGrid->B3i[k][j][i] = U1d.Bz;
00068         if (i == ie) pGrid->B1i[k][j][i+1] = Bx;
00069         if (j == je) pGrid->B2i[k][j+1][i] = U1d.By;
00070         if (k == ke && ke > ks) pGrid->B3i[k+1][j][i] = U1d.Bz;
00071         if (x1 > 0.5 && x1 < 1.5) {
00072           pGrid->B2i[k][j][i] = -U1d.By;
00073           pGrid->U[k][j][i].B2c = -U1d.By;
00074           if (j == je) pGrid->B2i[k][j+1][i] = -U1d.By;
00075         }
00076       }
00077     }
00078   }
00079 
00080 }
00081 
00082 /*==============================================================================
00083  * PROBLEM USER FUNCTIONS:
00084  * problem_write_restart() - writes problem-specific user data to restart files
00085  * problem_read_restart()  - reads problem-specific user data from restart files
00086  * get_usr_expr()          - sets pointer to expression for special output data
00087  * get_usr_out_fun()       - returns a user defined output function pointer
00088  * get_usr_par_prop()      - returns a user defined particle selection function
00089  * Userwork_in_loop        - problem specific work IN     main loop
00090  * Userwork_after_loop     - problem specific work AFTER  main loop
00091  *----------------------------------------------------------------------------*/
00092 
00093 void problem_write_restart(MeshS *pM, FILE *fp)
00094 {
00095   return;
00096 }
00097 
00098 void problem_read_restart(MeshS *pM, FILE *fp)
00099 {
00100   return;
00101 }
00102 
00103 ConsFun_t get_usr_expr(const char *expr)
00104 {
00105   return NULL;
00106 }
00107 
00108 VOutFun_t get_usr_out_fun(const char *name){
00109   return NULL;
00110 }
00111 
00112 void Userwork_in_loop(MeshS *pM)
00113 {
00114 }
00115 
00116 void Userwork_after_loop(MeshS *pM)
00117 {
00118 }

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