Ejemplo n.º 1
0
int main()
{
  double sol=0;
  double q=0;
  double x  = 1.2;
  double x2 = 2.2;
  char* a= "A_x";
  
  sol = 0;

  // init
  masa_init("nick","heateq_1d_steady_const");
  masa_init("bob","heateq_1d_steady_const");

  // reroute stdout: comment to display to screen
  freopen("/dev/null","w",stdout);
  
  // we can list initialized mms with 
   masa_list_mms();

  // switch
  masa_select_mms("nick");
  
  // we can display the parameter list with
  masa_display_param();

  // lets examine a particular parameter 
  q=masa_get_param(a);

  // now lets change that parameters value to something else.
  masa_set_param(a,1.984);
  q=masa_get_param(a);

  //check all initialized properly
  masa_sanity_check();
  sol = masa_eval_1d_source_t(x);
  
  masa_select_mms("bob");
  sol = masa_eval_1d_source_t(x2);
  return 0; // done
}
Ejemplo n.º 2
0
int main()
{
  int i;

  double tfield,tfield2,tfield3;
  double exact_t,exact_t2,exact_t3;
  double x;

  double A_x;
  double k_0;

  //problem size
  int nx = 200;  // number of points
  int lx=10;     // length
  double dx = (double)lx/(double)nx;

  // initalize everyone
  masa_init("temp-test-1d","heateq_1d_steady_const");
  masa_init_param();
  masa_sanity_check();

  A_x = masa_get_param("A_x");
  k_0 = masa_get_param("k_0"); 

  // evaluate source terms (1D)
  for(i=0;i<nx;i++)
    {
      x=i*dx;
      
      //evalulate source terms
      tfield = masa_eval_1d_source_t(x);
      
      //evaluate analytical terms
      exact_t   = masa_eval_1d_exact_t(x);
	
      // get fundamental source term solution
      tfield2   = SourceQ_t_1d  (x,A_x,k_0);
      exact_t2     = Source_t_1d_exact(x,A_x);

      // test the result is roughly zero
      // choose between abs and rel error
#ifdef MASA_STRICT_REGRESSION

      tfield3 = fabs(tfield-tfield2);
      exact_t3   = fabs(exact_t-exact_t2);

#else

      tfield3 = fabs(tfield-tfield2)/fabs(tfield2);
      exact_t3   = fabs(exact_t-exact_t2)/fabs(tfield2);

#endif

	if(tfield3 > threshold)
	  {
	    printf("\nMASA REGRESSION TEST FAILED: C-binding Heat Equation Steady-2d\n");
	    printf("U Field Source Term\n");
	    printf("Threshold Exceeded: %g\n",tfield3);
	    printf("MASA:              %5.16f\n",tfield);
	    printf("Maple:              %5.16f\n",tfield2);
	    exit(1);
	  }

	if(exact_t3 > threshold)
	  {
	    printf("\nMASA REGRESSION TEST FAILED: C-binding Heat Equation Steady-2d\n");
	    printf("U Field Analytical Term\n");
	    printf("Threshold Exceeded: %g\n",exact_t3);
	    printf("MASA:              %5.16f\n",exact_t);
	    printf("Maple:              %5.16f\n",exact_t2);
	    exit(1);
	  }
    } // done iterating


  masa_init("temp-test-2d","heateq_2d_steady_const");
  masa_init_param();
  masa_sanity_check();  

  masa_init("temp-test-3d","heateq_3d_steady_const");
  masa_init_param();
  masa_sanity_check();

  return 0; // steady as she goes

}