示例#1
0
int main(int argc, char* argv[])
{
  // Register new solver
  GRINS::SolverFactoryBasic<GRINS::PressureContinuationSolver>
    press_solver_factory("pressure_continuation");

  GRINS::Runner grins(argc,argv);

  grins.init();
  grins.run();

  return 0;
}
示例#2
0
int main(int argc, char* argv[])
{
#ifdef GRINS_USE_GRVY_TIMERS
  GRVY::GRVY_Timer_Class grvy_timer;
  grvy_timer.Init("GRINS Timer");
#endif

  // Check command line count.
  if( argc < 2 )
    {
      // TODO: Need more consistent error handling.
      std::cerr << "Error: Must specify libMesh input file." << std::endl;
      exit(1); // TODO: something more sophisticated for parallel runs?
    }

  // libMesh input file should be first argument
  std::string libMesh_input_filename = argv[1];
  
  // Create our GetPot object.
  GetPot libMesh_inputfile( libMesh_input_filename );

#ifdef GRINS_USE_GRVY_TIMERS
  grvy_timer.BeginTimer("Initialize Solver");
#endif

  // Initialize libMesh library.
  LibMeshInit libmesh_init(argc, argv);
 
  GRINS::SimulationBuilder sim_builder;

  GRINS::Simulation grins( libMesh_inputfile,
			   sim_builder );

#ifdef GRINS_USE_GRVY_TIMERS
  grvy_timer.EndTimer("Initialize Solver");

  // Attach GRVY timer to solver
  grins.attach_grvy_timer( &grvy_timer );
#endif

grins.run();

#ifdef GRINS_USE_GRVY_TIMERS
  grvy_timer.Finalize();
 
  if( Parallel::Communicator_World.rank() == 0 ) grvy_timer.Summarize();
#endif

  return 0;
}
示例#3
0
int main(int argc, char* argv[])
{
  // Check command line count.
  if( argc < 3 )
    {
      // TODO: Need more consistent error handling.
      std::cerr << "Error: Must specify libMesh input file and exact solution file." << std::endl;
      exit(1); // TODO: something more sophisticated for parallel runs?
    }

  GRINS::Runner grins(argc,argv);

  int return_flag = 0;

  return_flag = run( argv, grins );

  return return_flag;
}
示例#4
0
int main(int argc, char* argv[])
{
  GRINS::Runner grins(argc,argv);
  grins.init();

  const GetPot & inputfile = grins.get_input_file();

  //FIXME: We need to move this to within the Simulation object somehow...
  std::string restart_file = inputfile( "restart-options/restart_file", "none" );

  if( restart_file == "none" )
    {
      GRINS::Simulation & sim = grins.get_simulation();

      // Asssign initial temperature value
      std::string system_name = inputfile( "screen-options/system_name", "GRINS" );
      std::shared_ptr<libMesh::EquationSystems> es = sim.get_equation_system();
      const libMesh::System& system = es->get_system(system_name);

      libMesh::Parameters &params = es->parameters;
      libMesh::Real T_init = inputfile("Materials/Gas/ReferenceTemperature/value", 0.0);
      libMesh::Real p0_init = inputfile("Materials/Gas/ThermodynamicPressure/value", 0.0);

      libMesh::Real& dummy_T  = params.set<libMesh::Real>("T_init");
      dummy_T = T_init;

      libMesh::Real& dummy_p0 = params.set<libMesh::Real>("p0_init");
      dummy_p0 = p0_init;

      system.project_solution( initial_values, NULL, params );
    }

  grins.run();

  return 0;
}
示例#5
0
int main(int argc, char* argv[])
{
  /* Echo GRINS version, libMesh version, and command */
  libMesh::out << "=========================================================="
               << std::endl;
  libMesh::out << "GRINS Version: " << GRINS_BUILD_VERSION << std::endl
               << "libMesh Version: " << LIBMESH_BUILD_VERSION << std::endl
               << "Running with command:\n";

  for (int i=0; i != argc; ++i)
    std::cout << argv[i] << ' ';

  std::cout << std::endl
            << "=========================================================="
            << std::endl;

#ifdef GRINS_USE_GRVY_TIMERS
  GRVY::GRVY_Timer_Class grvy_timer;
  grvy_timer.Init("GRINS Timer");
#endif

  // Check command line count.
  if( argc < 2 )
    {
      // TODO: Need more consistent error handling.
      std::cerr << "Error: Must specify libMesh input file." << std::endl;
      exit(1); // TODO: something more sophisticated for parallel runs?
    }

  // libMesh input file should be first argument
  std::string libMesh_input_filename = argv[1];
  
  // Initialize libMesh library.
  libMesh::LibMeshInit libmesh_init(argc, argv);

  // Create our GetPot object.
  GetPot libMesh_inputfile( libMesh_input_filename );

  GetPot command_line(argc,argv);

  // GetPot doesn't throw an error for a nonexistent file?
  {
    std::ifstream i(libMesh_input_filename.c_str());
    if (!i)
      {
        std::cerr << "Error: Could not read from libMesh input file "
                << libMesh_input_filename << std::endl;
        exit(1);
      }
  }

#ifdef GRINS_USE_GRVY_TIMERS
  grvy_timer.BeginTimer("Initialize Solver");
#endif

  GRINS::SimulationBuilder sim_builder;

  GRINS::Simulation grins( libMesh_inputfile,
                           command_line,
			   sim_builder,
                           libmesh_init.comm() );

#ifdef GRINS_USE_GRVY_TIMERS
  grvy_timer.EndTimer("Initialize Solver");

  // Attach GRVY timer to solver
  grins.attach_grvy_timer( &grvy_timer );
#endif

grins.run();

#ifdef GRINS_USE_GRVY_TIMERS
  grvy_timer.Finalize();
 
  if( Parallel::Communicator_World.rank() == 0 ) grvy_timer.Summarize();
#endif

  return 0;
}
int main(int argc, char* argv[]) 
{

#ifdef GRINS_USE_GRVY_TIMERS
  GRVY::GRVY_Timer_Class grvy_timer;
  grvy_timer.Init("GRINS Timer");
#endif

  // Check command line count.
  if( argc < 2 )
    {
      // TODO: Need more consistent error handling.
      std::cerr << "Error: Must specify libMesh input file." << std::endl;
      exit(1); // TODO: something more sophisticated for parallel runs?
    }

  // libMesh input file should be first argument
  std::string libMesh_input_filename = argv[1];
  
  // Create our GetPot object.
  GetPot libMesh_inputfile( libMesh_input_filename );

#ifdef GRINS_USE_GRVY_TIMERS
  grvy_timer.BeginTimer("Initialize Solver");
#endif

  // Initialize libMesh library.
  libMesh::LibMeshInit libmesh_init(argc, argv);
 
  GRINS::SimulationBuilder sim_builder;

  GRINS::SharedPtr<GRINS::BoundaryConditionsFactory> bc_factory( new ParabolicBCFactory );

  sim_builder.attach_bc_factory(bc_factory);

  GRINS::Simulation grins( libMesh_inputfile,
			   sim_builder,
                           libmesh_init.comm() );

#ifdef GRINS_USE_GRVY_TIMERS
  grvy_timer.EndTimer("Initialize Solver");

  // Attach GRVY timer to solver
  grins.attach_grvy_timer( &grvy_timer );
#endif

  // Solve
  grins.run();

  // Get equation systems to create ExactSolution object
  GRINS::SharedPtr<libMesh::EquationSystems> es = grins.get_equation_system();

  // Create Exact solution object and attach exact solution quantities
  libMesh::ExactSolution exact_sol(*es);

  exact_sol.attach_exact_value(&exact_solution);
  exact_sol.attach_exact_deriv(&exact_derivative);
  
  // Compute error and get it in various norms
  exact_sol.compute_error("GRINS", "u");

  double l2error = exact_sol.l2_error("GRINS", "u");
  double h1error = exact_sol.h1_error("GRINS", "u");

  int return_flag = 0;

  const double tol = 1.0e-8;

  if( l2error > tol || h1error > tol )
    {
      return_flag = 1;

      std::cout << "Tolerance exceeded for velocity in Poiseuille test." << std::endl
		<< "l2 error = " << l2error << std::endl
		<< "h1 error = " << h1error << std::endl;
    }

  // Compute error and get it in various norms
  exact_sol.compute_error("GRINS", "p");

  l2error = exact_sol.l2_error("GRINS", "p");
  h1error = exact_sol.h1_error("GRINS", "p");

  if( l2error > tol || h1error > tol )
    {
      return_flag = 1;

      std::cout << "Tolerance exceeded for pressure in Poiseuille test." << std::endl
		<< "l2 error = " << l2error << std::endl
		<< "h1 error = " << h1error << std::endl;
    }

  return return_flag;
}
int main(int argc, char* argv[])
{
#ifdef GRINS_USE_GRVY_TIMERS
    GRVY::GRVY_Timer_Class grvy_timer;
    grvy_timer.Init("GRINS Timer");
#endif

    // Check command line count.
    if( argc < 3 )
    {
        // TODO: Need more consistent error handling.
        std::cerr << "Error: Must specify libMesh input file and solution file." << std::endl;
        exit(1); // TODO: something more sophisticated for parallel runs?
    }

    // libMesh input file should be first argument
    std::string libMesh_input_filename = argv[1];

    // Create our GetPot object.
    GetPot libMesh_inputfile( libMesh_input_filename );

#ifdef GRINS_USE_GRVY_TIMERS
    grvy_timer.BeginTimer("Initialize Solver");
#endif

    // Initialize libMesh library.
    libMesh::LibMeshInit libmesh_init(argc, argv);

    GRINS::SimulationBuilder sim_builder;

    sim_builder.attach_bc_factory( GRINS::SharedPtr<GRINS::BoundaryConditionsFactory>( new GRINS::ThermallyDrivenFlowTestBCFactory( libMesh_inputfile ) ) );

    GRINS::Simulation grins( libMesh_inputfile,
                             sim_builder,
                             libmesh_init.comm() );

#ifdef GRINS_USE_GRVY_TIMERS
    grvy_timer.EndTimer("Initialize Solver");

    // Attach GRVY timer to solver
    grins.attach_grvy_timer( &grvy_timer );
#endif

    // Do solve here
    grins.run();

    // Get equation systems to create ExactSolution object
    GRINS::SharedPtr<libMesh::EquationSystems> es = grins.get_equation_system();

    //es->write("foobar.xdr");

    // Create Exact solution object and attach exact solution quantities
    libMesh::ExactSolution exact_sol(*es);

    libMesh::EquationSystems es_ref( es->get_mesh() );

    // Filename of file where comparison solution is stashed
    std::string solution_file = std::string(argv[2]);
    es_ref.read( solution_file );

    exact_sol.attach_reference_solution( &es_ref );

    // Compute error and get it in various norms
    exact_sol.compute_error("GRINS", "u");
    exact_sol.compute_error("GRINS", "v");

    if( (es->get_mesh()).mesh_dimension() == 3 )
        exact_sol.compute_error("GRINS", "w");

    exact_sol.compute_error("GRINS", "p");
    exact_sol.compute_error("GRINS", "T");

    double u_l2error = exact_sol.l2_error("GRINS", "u");
    double u_h1error = exact_sol.h1_error("GRINS", "u");

    double v_l2error = exact_sol.l2_error("GRINS", "v");
    double v_h1error = exact_sol.h1_error("GRINS", "v");

    double p_l2error = exact_sol.l2_error("GRINS", "p");
    double p_h1error = exact_sol.h1_error("GRINS", "p");

    double T_l2error = exact_sol.l2_error("GRINS", "T");
    double T_h1error = exact_sol.h1_error("GRINS", "T");

    double w_l2error = 0.0,
           w_h1error = 0.0;

    if( (es->get_mesh()).mesh_dimension() == 3 )
    {
        w_l2error = exact_sol.l2_error("GRINS", "w");
        w_h1error = exact_sol.h1_error("GRINS", "w");
    }

    int return_flag = 0;

    // This is the tolerance of the iterative linear solver so
    // it's unreasonable to expect anything better than this.
    double tol = 8.0e-9;

    if( u_l2error > tol || u_h1error > tol ||
            v_l2error > tol || v_h1error > tol ||
            w_l2error > tol || w_h1error > tol ||
            p_l2error > tol || p_h1error > tol ||
            T_l2error > tol || T_h1error > tol   )
    {
        return_flag = 1;

        std::cout << "Tolerance exceeded for thermally driven flow test." << std::endl
                  << "tolerance = " << tol << std::endl
                  << "u l2 error = " << u_l2error << std::endl
                  << "u h1 error = " << u_h1error << std::endl
                  << "v l2 error = " << v_l2error << std::endl
                  << "v h1 error = " << v_h1error << std::endl
                  << "w l2 error = " << w_l2error << std::endl
                  << "w h1 error = " << w_h1error << std::endl
                  << "p l2 error = " << p_l2error << std::endl
                  << "p h1 error = " << p_h1error << std::endl
                  << "T l2 error = " << T_l2error << std::endl
                  << "T h1 error = " << T_h1error << std::endl;
    }

    return return_flag;
}
int run( int argc, char* argv[], const GetPot& input )
{
  // Initialize libMesh library.
  libMesh::LibMeshInit libmesh_init(argc, argv);
 
  GRINS::SimulationBuilder sim_builder;

  std::tr1::shared_ptr<GRINS::BoundaryConditionsFactory> bc_factory( new NitridationCalibration::BoundaryConditionsFactory(input) );

  sim_builder.attach_bc_factory( bc_factory );

  std::tr1::shared_ptr<GRINS::QoIFactory> qoi_factory( new NitridationCalibration::QoIFactory );

  sim_builder.attach_qoi_factory( qoi_factory );

  GRINS::Simulation grins( input,
			   sim_builder,
                           libmesh_init.comm());

  //FIXME: We need to move this to within the Simulation object somehow...
  std::string restart_file = input( "restart-options/restart_file", "none" );

  std::tr1::shared_ptr<NitridationCalibration::TubeTempBC> wall_temp;
  
  std::string system_name = input( "screen-options/system_name", "GRINS" );

  if( restart_file == "none" )
    {
      // Asssign initial temperature value
      std::tr1::shared_ptr<libMesh::EquationSystems> es = grins.get_equation_system();
      const libMesh::System& system = es->get_system(system_name);
      
      libMesh::Parameters &params = es->parameters;

      libMesh::Real& w_N2 = params.set<libMesh::Real>( "w_N2" );
      w_N2 = input( "Physics/ReactingLowMachNavierStokes/bound_species_1", 0.0, 0 );
      
      libMesh::Real& w_N = params.set<libMesh::Real>( "w_N" );
      w_N = input( "Physics/ReactingLowMachNavierStokes/bound_species_1", 0.0, 1 );

      wall_temp.reset( new NitridationCalibration::TubeTempBC( input ) );
      std::tr1::shared_ptr<NitridationCalibration::TubeTempBC>& dummy = params.set<std::tr1::shared_ptr<NitridationCalibration::TubeTempBC> >( "wall_temp" );
      dummy = wall_temp;

      system.project_solution( initial_values, NULL, params );
    }

  grins.run();

  // Get equation systems to create ExactSolution object
  std::tr1::shared_ptr<libMesh::EquationSystems> es = grins.get_equation_system();

  //es->write("foobar.xdr");

  // Create Exact solution object and attach exact solution quantities
  libMesh::ExactSolution exact_sol(*es);
  
  libMesh::EquationSystems es_ref( es->get_mesh() );

  // Filename of file where comparison solution is stashed
  std::string solution_file = std::string(argv[2]);
  es_ref.read( solution_file );

  exact_sol.attach_reference_solution( &es_ref );
  
  // Compute error and get it in various norms
  exact_sol.compute_error(system_name, "u");
  exact_sol.compute_error(system_name, "v");

  if( (es->get_mesh()).mesh_dimension() == 3 )
    exact_sol.compute_error(system_name, "w");

  exact_sol.compute_error(system_name, "p");
  exact_sol.compute_error(system_name, "T");
  exact_sol.compute_error(system_name, "w_N2");
  exact_sol.compute_error(system_name, "w_N");
  exact_sol.compute_error(system_name, "w_CN");

  double u_l2error = exact_sol.l2_error(system_name, "u");
  double u_h1error = exact_sol.h1_error(system_name, "u");

  double v_l2error = exact_sol.l2_error(system_name, "v");
  double v_h1error = exact_sol.h1_error(system_name, "v");

  double p_l2error = exact_sol.l2_error(system_name, "p");
  double p_h1error = exact_sol.h1_error(system_name, "p");

  double T_l2error = exact_sol.l2_error(system_name, "T");
  double T_h1error = exact_sol.h1_error(system_name, "T");

  double wN_l2error = exact_sol.l2_error(system_name, "w_N");
  double wN_h1error = exact_sol.h1_error(system_name, "w_N");

  double wN2_l2error = exact_sol.l2_error(system_name, "w_N2");
  double wN2_h1error = exact_sol.h1_error(system_name, "w_N2");

  double wCN_l2error = exact_sol.l2_error(system_name, "w_CN");
  double wCN_h1error = exact_sol.h1_error(system_name, "w_CN");
  
  double w_l2error = 0.0, 
         w_h1error = 0.0;

  if( (es->get_mesh()).mesh_dimension() == 3 )
    {
      w_l2error = exact_sol.l2_error(system_name, "w");
      w_h1error = exact_sol.h1_error(system_name, "w");
    }

  int return_flag = 0;

  // This is the tolerance of the iterative linear solver so
  // it's unreasonable to expect anything better than this.
  double tol = 5.0e-10;
  
  if( u_l2error > tol   || u_h1error > tol   ||
      v_l2error > tol   || v_h1error > tol   ||
      w_l2error > tol   || w_h1error > tol   ||
      p_l2error > tol   || p_h1error > tol   ||
      T_l2error > tol   || T_h1error > tol   ||
      wN_l2error > tol  || wN_h1error > tol  ||
      wN2_l2error > tol || wN2_h1error > tol ||
      wCN_l2error > tol || wCN_h1error > tol )
    {
      return_flag = 1;

      std::cout << "Tolerance exceeded for solution fields." << std::endl
		<< "tolerance     = " << tol << std::endl
		<< "u l2 error    = " << u_l2error << std::endl
		<< "u h1 error    = " << u_h1error << std::endl
		<< "v l2 error    = " << v_l2error << std::endl
		<< "v h1 error    = " << v_h1error << std::endl
		<< "w l2 error    = " << w_l2error << std::endl
		<< "w h1 error    = " << w_h1error << std::endl
		<< "p l2 error    = " << p_l2error << std::endl
		<< "p h1 error    = " << p_h1error << std::endl
		<< "T l2 error    = " << T_l2error << std::endl
		<< "T h1 error    = " << T_h1error << std::endl
		<< "w_N l2 error  = " << wN_l2error << std::endl
		<< "w_N h1 error  = " << wN_h1error << std::endl
		<< "w_N2 l2 error = " << wN2_l2error << std::endl
		<< "w_N2 h1 error = " << wN2_h1error << std::endl
                << "w_CN l2 error = " << wCN_l2error << std::endl
                << "w_CN h1 error = " << wCN_h1error << std::endl;
    }

  // Now test QoI Values
  const libMesh::Real mass_loss_reg = atof(argv[3]);
  const libMesh::Real avg_N_reg = atof(argv[4]);
  
  /* The value we compute is negative by convention, but the data are given
     as positive by convention, so convert to data convention. */
  const libMesh::Real mass_loss_comp = std::fabs(grins.get_qoi_value(0));
  const libMesh::Real avg_N_comp = grins.get_qoi_value(1);
  
  const double qoi_tol = 1.0e-9;

  const double mass_loss_error = std::fabs( (mass_loss_comp - mass_loss_reg)/mass_loss_reg );

  const double avg_N_error = std::fabs( (avg_N_comp - avg_N_reg)/avg_N_reg );

  if( mass_loss_error > qoi_tol ||
      avg_N_error > qoi_tol )
    {
      return_flag = 1;

       std::cout << "Tolerance exceeded for qoi values." << std::endl
                 << "tolerance       = " << qoi_tol << std::endl
                 << "mass loss       = " << mass_loss_comp << std::endl
                 << "avg N           = " << avg_N_comp << std::endl
                 << "mass loss error = " << mass_loss_error << std::endl
                 << "avg N error     = " << avg_N_error << std::endl;
    }

  return return_flag;
}
int main(int argc, char* argv[])
{
  GRINS::Runner grins(argc,argv);

  // This is a tough problem to get to converge without PETSc
  libmesh_example_requires
    (libMesh::default_solver_package() != libMesh::LASPACK_SOLVERS,
     "--enable-petsc");

  grins.init();

  const GetPot & inputfile = grins.get_input_file();

  GRINS::Simulation & sim = grins.get_simulation();

  //FIXME: We need to move this to within the Simulation object somehow...
  std::string restart_file = inputfile( "restart-options/restart_file", "none" );

  if( restart_file == "none" )
    {
      // Asssign initial temperature value
      std::string system_name = inputfile( "screen-options/system_name", "GRINS" );
      std::shared_ptr<libMesh::EquationSystems> es = sim.get_equation_system();
      const libMesh::System& system = es->get_system(system_name);

      libMesh::Parameters &params = es->parameters;
      libMesh::Real T_init = inputfile("Materials/TestMaterial/ReferenceTemperature/value", 0.0);
      libMesh::Real p0_init = inputfile("Materials/TestMaterial/ThermodynamicPressure/value", 0.0);

      libMesh::Real& dummy_T  = params.set<libMesh::Real>("T_init");
      dummy_T = T_init;

      libMesh::Real& dummy_p0 = params.set<libMesh::Real>("p0_init");
      dummy_p0 = p0_init;

      system.project_solution( initial_values, NULL, params );
    }

  grins.run();

  libMesh::Real qoi = sim.get_qoi_value(0);

  // Note that this is a *really* coarse mesh. This is just for testing
  // and not even close to the real QoI for this problem.

  // Erroneous value from libMesh 0.9.2.2
  // const libMesh::Real exact_qoi = 4.8158910676325055;

  // Value after libMesh 7acb6fc9 bugfix
  const libMesh::Real exact_qoi = 4.8654229502012685;

  const libMesh::Real tol = 1.0e-9;

  int return_flag = 0;

  libMesh::Real rel_error = std::fabs( (qoi-exact_qoi)/exact_qoi );

  if( rel_error > tol )
    {
      // Skip this test until we know what changed
      // return_flag = 1;
      return_flag = 77;

      std::cerr << std::setprecision(16)
                << std::scientific
                << "Error: QoI value mismatch." << std::endl
                << "Computed qoi   = " << qoi << std::endl
                << "Exact qoi      = " << exact_qoi << std::endl
                << "Relative error = " << rel_error << std::endl;
    }

  return return_flag;
}
int run( int argc, char* argv[], const GetPot& input, GetPot& command_line )
{
  // Initialize libMesh library.
  libMesh::LibMeshInit libmesh_init(argc, argv);

  GRINS::SimulationBuilder sim_builder;

  GRINS::Simulation grins( input,
			   sim_builder,
                           libmesh_init.comm() );

  //FIXME: We need to move this to within the Simulation object somehow...
  std::string restart_file = input( "restart-options/restart_file", "none" );

  if( restart_file == "none" )
    {
      // Asssign initial temperature value
      std::string system_name = input( "screen-options/system_name", "GRINS" );
      std::tr1::shared_ptr<libMesh::EquationSystems> es = grins.get_equation_system();
      const libMesh::System& system = es->get_system(system_name);

      libMesh::Parameters &params = es->parameters;

      libMesh::Real& w_N2 = params.set<libMesh::Real>( "w_N2" );
      w_N2 = input( "Physics/ReactingLowMachNavierStokes/bound_species_0", 0.0, 0.0 );

      libMesh::Real& w_N = params.set<libMesh::Real>( "w_N" );
      w_N = input( "Physics/ReactingLowMachNavierStokes/bound_species_0", 0.0, 1.0 );

      system.project_solution( initial_values, NULL, params );
    }

  grins.run();

  // Get equation systems to create ExactSolution object
  std::tr1::shared_ptr<libMesh::EquationSystems> es = grins.get_equation_system();

   // Create Exact solution object and attach exact solution quantities
  libMesh::ExactSolution exact_sol(*es);

  libMesh::EquationSystems es_ref( es->get_mesh() );

  // Filename of file where comparison solution is stashed
  std::string solution_file = command_line("soln-data", "DIE!");
  es_ref.read( solution_file );

  exact_sol.attach_reference_solution( &es_ref );

  // Now grab the variables for which we want to compare
  unsigned int n_vars = command_line.vector_variable_size("vars");
  std::vector<std::string> vars(n_vars);
  for( unsigned int v = 0; v < n_vars; v++ )
    {
      vars[v] = command_line("vars", "DIE!", v);
    }

  // Now grab the norms to compute for each variable error
  unsigned int n_norms = command_line.vector_variable_size("norms");
  std::vector<std::string> norms(n_norms);
  for( unsigned int n = 0; n < n_norms; n++ )
    {
      norms[n] = command_line("norms", "DIE!", n);
      if( norms[n] != std::string("L2") &&
          norms[n] != std::string("H1") )
        {
          std::cerr << "ERROR: Invalid norm input " << norms[n] << std::endl
                    << "       Valid values are: L2" << std::endl
                    << "                         H1" << std::endl;
        }
    }

  const std::string& system_name = grins.get_multiphysics_system_name();

  // Now compute error for each variable
  for( unsigned int v = 0; v < n_vars; v++ )
    {
      exact_sol.compute_error(system_name, vars[v]);
    }

  int return_flag = 0;

  double tol = command_line("tol", 1.0e-10);

  // Now test error for each variable, for each norm
  for( unsigned int v = 0; v < n_vars; v++ )
    {
      for( unsigned int n = 0; n < n_norms; n++ )
        {
          test_error_norm( exact_sol, system_name, vars[v], norms[n], tol, return_flag );
        }
    }

  return return_flag;
}
示例#11
0
int main(int argc, char* argv[])
{
#ifdef GRINS_USE_GRVY_TIMERS
  GRVY::GRVY_Timer_Class grvy_timer;
  grvy_timer.Init("GRINS Timer");
#endif

  // Check command line count.
  if( argc < 2 )
    {
      // TODO: Need more consistent error handling.
      std::cerr << "Error: Must specify libMesh input file." << std::endl;
      exit(1); // TODO: something more sophisticated for parallel runs?
    }

  // libMesh input file should be first argument
  std::string libMesh_input_filename = argv[1];
  
  // Create our GetPot object.
  GetPot libMesh_inputfile( libMesh_input_filename );

#ifdef GRINS_USE_GRVY_TIMERS
  grvy_timer.BeginTimer("Initialize Solver");
#endif

  // Initialize libMesh library.
  libMesh::LibMeshInit libmesh_init(argc, argv);
 
  GRINS::SimulationBuilder sim_builder;

  GRINS::Simulation grins( libMesh_inputfile,
			   sim_builder,
                           libmesh_init.comm() );

  //FIXME: We need to move this to within the Simulation object somehow...
  std::string restart_file = libMesh_inputfile( "restart-options/restart_file", "none" );

  if( restart_file == "none" )
    {
      // Asssign initial temperature value
      std::string system_name = libMesh_inputfile( "screen-options/system_name", "GRINS" );
      std::tr1::shared_ptr<libMesh::EquationSystems> es = grins.get_equation_system();
      const libMesh::System& system = es->get_system(system_name);
      
      libMesh::Parameters &params = es->parameters;
      libMesh::Real T_init = libMesh_inputfile("Physics/LowMachNavierStokes/T0", 0.0);
      libMesh::Real p0_init = libMesh_inputfile("Physics/LowMachNavierStokes/p0", 0.0);

      libMesh::Real& dummy_T  = params.set<libMesh::Real>("T_init");
      dummy_T = T_init;

      libMesh::Real& dummy_p0 = params.set<libMesh::Real>("p0_init");
      dummy_p0 = p0_init;

      system.project_solution( initial_values, NULL, params );
    }

#ifdef GRINS_USE_GRVY_TIMERS
  grvy_timer.EndTimer("Initialize Solver");

  // Attach GRVY timer to solver
  grins.attach_grvy_timer( &grvy_timer );
#endif

  grins.run();

#ifdef GRINS_USE_GRVY_TIMERS
  grvy_timer.Finalize();
 
  if( Parallel::Communicator_World.rank() == 0 ) grvy_timer.Summarize();
#endif

  return 0;
}
示例#12
0
int main(int argc, char* argv[])
{
  // Check command line count.
  if( argc < 4 )
    {
      // TODO: Need more consistent error handling.
      std::cerr << "Error: Must specify libMesh input file, regression file, and regression tolerance." << std::endl;
      exit(1); // TODO: something more sophisticated for parallel runs?
    }

  // libMesh input file should be first argument
  std::string libMesh_input_filename = argv[1];
  
  // Create our GetPot object.
  GetPot libMesh_inputfile( libMesh_input_filename );

  // Initialize libMesh library.
  LibMeshInit libmesh_init(argc, argv);
 
  GRINS::SimulationBuilder sim_builder;

  GRINS::Simulation grins( libMesh_inputfile,
			   sim_builder,
                           libmesh_init.comm() );

  grins.run();

  // Get equation systems to create ExactSolution object
  std::tr1::shared_ptr<EquationSystems> es = grins.get_equation_system();

  //es->write("foobar.xdr");

  // Create Exact solution object and attach exact solution quantities
  ExactSolution exact_sol(*es);
  
  EquationSystems es_ref( es->get_mesh() );

  // Filename of file where comparison solution is stashed
  std::string solution_file = std::string(argv[2]);
  es_ref.read( solution_file );

  exact_sol.attach_reference_solution( &es_ref );
  
  std::string system_name = libMesh_inputfile( "screen-options/system_name", "GRINS" );

  // Compute error and get it in various norms
  exact_sol.compute_error(system_name, "u");
  exact_sol.compute_error(system_name, "v");

  exact_sol.compute_error(system_name, "p");

  double u_l2error = exact_sol.l2_error(system_name, "u");
  double u_h1error = exact_sol.h1_error(system_name, "u");

  double v_l2error = exact_sol.l2_error(system_name, "v");
  double v_h1error = exact_sol.h1_error(system_name, "v");

  double p_l2error = exact_sol.l2_error(system_name, "p");
  double p_h1error = exact_sol.h1_error(system_name, "p");

  int return_flag = 0;

  // This is the tolerance of the iterative linear solver so
  // it's unreasonable to expect anything better than this.
  double tol = atof(argv[3]);
  
  if( u_l2error > tol || u_h1error > tol ||
      v_l2error > tol || v_h1error > tol ||
      p_l2error > tol || p_h1error > tol  )
    {
      return_flag = 1;

      std::cout << "Tolerance exceeded for thermally driven flow test." << std::endl
		<< "tolerance = " << tol << std::endl
		<< "u l2 error = " << u_l2error << std::endl
		<< "u h1 error = " << u_h1error << std::endl
		<< "v l2 error = " << v_l2error << std::endl
		<< "v h1 error = " << v_h1error << std::endl
		<< "p l2 error = " << p_l2error << std::endl
		<< "p h1 error = " << p_h1error << std::endl;
    }

 return return_flag;
}
示例#13
0
int main(int argc, char* argv[]) 
{

#ifdef GRINS_USE_GRVY_TIMERS
  GRVY::GRVY_Timer_Class grvy_timer;
  grvy_timer.Init("GRINS Timer");
#endif

  // Check command line count.
  if( argc < 2 )
    {
      // TODO: Need more consistent error handling.
      std::cerr << "Error: Must specify libMesh input file." << std::endl;
      exit(1); // TODO: something more sophisticated for iarallel runs?
    }

  // libMesh input file should be first argument
  std::string libMesh_input_filename = argv[1];
  
  // Create our GetPot object.
  GetPot libMesh_inputfile( libMesh_input_filename );

#ifdef GRINS_USE_GRVY_TIMERS
  grvy_timer.BeginTimer("Initialize Solver");
#endif

  // Initialize libMesh library.
  LibMeshInit libmesh_init(argc, argv);
 
  GRINS::SimulationBuilder sim_builder;

  GRINS::Simulation grins( libMesh_inputfile,
			   sim_builder,
                           libmesh_init.comm() );

#ifdef GRINS_USE_GRVY_TIMERS
  grvy_timer.EndTimer("Initialize Solver");

  // Attach GRVY timer to solver
  grins.attach_grvy_timer( &grvy_timer );
#endif

  // Solve
  grins.run();

  Number qoi = grins.get_qoi_value( 0 );

  int return_flag = 0;
  const Number exact_value = -0.5;
  const Number rel_error = std::fabs( (qoi - exact_value )/exact_value );
  const Number tol = 1.0e-15;
  if( rel_error > tol )
    {
      std::cerr << "Computed voriticity QoI mismatch greater than tolerance." << std::endl
		<< "Computed value = " << qoi << std::endl
		<< "Exact value = " << exact_value << std::endl
		<< "Relative error = " << rel_error << std::endl
		<< "Tolerance = " << tol << std::endl;
      return_flag = 1;
    }

  return return_flag;
}
示例#14
0
int main(int argc, char* argv[])
{
#ifdef GRINS_USE_GRVY_TIMERS
  GRVY::GRVY_Timer_Class grvy_timer;
  grvy_timer.Init("GRINS Timer");
#endif
	// Check command line count.
	if( argc < 3 )
	{
		// TODO: Need more consistent error handling.
		std::cerr << "Error: Must specify libMesh input file." << std::endl;
		exit(1); // TODO: something more sophisticated for parallel runs?
	}

	// libMesh input file should be first argument
	std::string libMesh_input_filename = argv[1];

	// Create our GetPot object.
	GetPot libMesh_inputfile( libMesh_input_filename );

	// GetPot doesn't throw an error for a nonexistent file?
	{
		std::ifstream i(libMesh_input_filename.c_str());
		if (!i)
		{
			std::cerr << "Error: Could not read from libMesh input file "
					<< libMesh_input_filename << std::endl;
			exit(1);
		}
	}

	// Initialize libMesh library.
	libMesh::LibMeshInit libmesh_init(argc, argv);

	libMesh::out << "Starting GRINS with command:\n";
	for (int i=0; i != argc; ++i)
		libMesh::out << argv[i] << ' ';
	libMesh::out << std::endl;

	GRINS::SimulationBuilder sim_builder;

	GRINS::Simulation grins( libMesh_inputfile,
						     sim_builder,
						     libmesh_init.comm() );

	std::string system_name = libMesh_inputfile( "screen-options/system_name", "GRINS" );

	// Get equation systems
	GRINS::SharedPtr<libMesh::EquationSystems> es = grins.get_equation_system();
	const libMesh::System& system = es->get_system(system_name);

	libMesh::Parameters &params = es->parameters;

	system.project_solution( initial_values, NULL, params );

	grins.run();

	//es->write("suspended_cable_test.xdr");

	// Create Exact solution object and attach exact solution quantities
	libMesh::ExactSolution exact_sol(*es);

	libMesh::EquationSystems es_ref( es->get_mesh() );

	// Filename of file where comparison solution is stashed
	std::string solution_file = std::string(argv[2]);
	es_ref.read( solution_file );

	exact_sol.attach_reference_solution( &es_ref );

	// Compute error and get it in various norms
	exact_sol.compute_error(system_name, "u");
	exact_sol.compute_error(system_name, "v");
	exact_sol.compute_error(system_name, "w");

	double u_l2error = exact_sol.l2_error(system_name, "u");
	double u_h1error = exact_sol.h1_error(system_name, "u");

	double v_l2error = exact_sol.l2_error(system_name, "v");
	double v_h1error = exact_sol.h1_error(system_name, "v");

	double w_l2error = exact_sol.l2_error(system_name, "w");
	double w_h1error = exact_sol.h1_error(system_name, "w");

	int return_flag = 0;

	double tol = 5.0e-8;

	if( u_l2error > tol   || u_h1error > tol   ||
	    v_l2error > tol   || v_h1error > tol   ||
	    w_l2error > tol   || w_h1error > tol     )
	{
	  return_flag = 1;

	  std::cout << "Tolerance exceeded for suspended cable test." << std::endl
		<< "tolerance     = " << tol << std::endl
		<< "u l2 error    = " << u_l2error << std::endl
		<< "u h1 error    = " << u_h1error << std::endl
		<< "v l2 error    = " << v_l2error << std::endl
		<< "v h1 error    = " << v_h1error << std::endl
		<< "w l2 error    = " << w_l2error << std::endl
		<< "w h1 error    = " << w_h1error << std::endl;
	}

	return return_flag;
}
示例#15
0
int main(int argc, char* argv[])
{
#ifdef GRINS_USE_GRVY_TIMERS
  GRVY::GRVY_Timer_Class grvy_timer;
  grvy_timer.Init("GRINS Timer");
#endif

  // Check command line count.
  if( argc < 2 )
    {
      // TODO: Need more consistent error handling.
      std::cerr << "Error: Must specify libMesh input file." << std::endl;
      exit(1); // TODO: something more sophisticated for parallel runs?
    }

  // libMesh input file should be first argument
  std::string libMesh_input_filename = argv[1];
  
  // Create our GetPot object.
  GetPot libMesh_inputfile( libMesh_input_filename );

#ifdef GRINS_USE_GRVY_TIMERS
  grvy_timer.BeginTimer("Initialize Solver");
#endif

  // Initialize libMesh library.
  LibMeshInit libmesh_init(argc, argv);
 
  GRINS::SimulationBuilder sim_builder;

  std::tr1::shared_ptr<BunsenBCFactory> bc_factory( new BunsenBCFactory );
  sim_builder.attach_bc_factory( bc_factory );

  std::tr1::shared_ptr<GRINS::PhysicsFactory> physics_factory( new BunsenPhysicsFactory );
  sim_builder.attach_physics_factory( physics_factory );

  GRINS::Simulation grins( libMesh_inputfile,
			   sim_builder );

  //FIXME: We need to move this to within the Simulation object somehow...
  std::string restart_file = libMesh_inputfile( "restart-options/restart_file", "none" );

  // If we are "cold starting", setup the flow field.
  if( restart_file == "none" )
    {
      // Asssign initial temperature value
      std::string system_name = libMesh_inputfile( "screen-options/system_name", "GRINS" );
      std::tr1::shared_ptr<libMesh::EquationSystems> es = grins.get_equation_system();
      const libMesh::System& system = es->get_system(system_name);
      
      Parameters &params = es->parameters;

      libMesh::Real& T_init = params.set<libMesh::Real>("T_init");
      T_init = libMesh_inputfile("InitialConditions/T0", 0.0);

      libMesh::Real& p0 = params.set<libMesh::Real>("p0");
      p0 = libMesh_inputfile("Physics/ReactingLowMachNavierStokes/p0", 1.0e5);

#ifdef GRINS_HAVE_CANTERA
      //Cantera::IdealGasMix& cantera = GRINS::CanteraSingleton::cantera_instance(libMesh_inputfile);
#endif

      libMesh::Real& w_H2 = params.set<libMesh::Real>( "w_H2" );
      w_H2 = libMesh_inputfile( "Physics/ReactingLowMachNavierStokes/bound_species_1", 0.0, 0 );

      libMesh::Real& w_O2 = params.set<libMesh::Real>( "w_O2" );
      w_O2 = libMesh_inputfile( "Physics/ReactingLowMachNavierStokes/bound_species_1", 0.0, 1 );

      libMesh::Real& w_H2O = params.set<libMesh::Real>( "w_H2O" );
      w_H2O = libMesh_inputfile( "Physics/ReactingLowMachNavierStokes/bound_species_1", 0.0, 2 );

      libMesh::Real& w_H = params.set<libMesh::Real>( "w_H" );
      w_H = libMesh_inputfile( "Physics/ReactingLowMachNavierStokes/bound_species_1", 0.0, 3 );

      libMesh::Real& w_O = params.set<libMesh::Real>( "w_O" );
      w_O = libMesh_inputfile( "Physics/ReactingLowMachNavierStokes/bound_species_1", 0.0, 4 );

      libMesh::Real& w_OH = params.set<libMesh::Real>( "w_OH" );
      w_OH = libMesh_inputfile( "Physics/ReactingLowMachNavierStokes/bound_species_1", 0.0, 5 );

      libMesh::Real& w_HO2 = params.set<libMesh::Real>( "w_HO2" );
      w_HO2 = libMesh_inputfile( "Physics/ReactingLowMachNavierStokes/bound_species_1", 0.0, 6 );

      libMesh::Real& w_H2O2 = params.set<libMesh::Real>( "w_H2O2" );
      w_H2O2 = libMesh_inputfile( "Physics/ReactingLowMachNavierStokes/bound_species_1", 0.0, 7 );

      libMesh::Real& w_N2 = params.set<libMesh::Real>( "w_N2" );
      w_N2 = libMesh_inputfile( "Physics/ReactingLowMachNavierStokes/bound_species_1", 0.0, 8 );

      std::cout << "==============================================" << std::endl;
      std::cout << "Projecting Solution." << std::endl;
      std::cout << "==============================================" << std::endl;
      system.project_solution( initial_values, NULL, params );
      std::cout << "==============================================" << std::endl;
      std::cout << "Done Projecting Solution!" << std::endl;
      std::cout << "==============================================" << std::endl;
    }

  /* If we're restarting to try and get ignition, then we need to setup a
     "restart" system and using the IgniteInitalGuess functor to do the projection
     on the "real" system. */
  if( libMesh_inputfile( "restart-options/ignition", false ) && 
      restart_file != std::string("none") )
    {
      std::string system_name = libMesh_inputfile( "screen-options/system_name", "GRINS" );

      /*
      GetPot restart_input( "bunsen_restart.in" );
      
      GRINS::Simulation restart_sim( restart_input,
				     sim_builder );
      std::tr1::shared_ptr<libMesh::EquationSystems> restart_es = restart_sim.get_equation_system();
      libMesh::System& restart_system = restart_es->get_system(system_name);
      GRINS::MultiphysicsSystem& restart_ms_system = libmesh_cast_ref<GRINS::MultiphysicsSystem&>( restart_system );
      */

      std::tr1::shared_ptr<libMesh::EquationSystems> es = grins.get_equation_system();
      libMesh::System& system = es->get_system(system_name);
      GRINS::MultiphysicsSystem& ms_system = libmesh_cast_ref<GRINS::MultiphysicsSystem&>( system );

      Bunsen::IgniteInitialGuess<libMesh::Real> ignite( libMesh_inputfile, ms_system, 
					       ms_system );

      es->reinit();
      
      std::cout << "==============================================" << std::endl;
      std::cout << "Projecting Solution." << std::endl;
      std::cout << "==============================================" << std::endl;
      ms_system.project_solution( &ignite );
      std::cout << "==============================================" << std::endl;
      std::cout << "Done Projecting Solution!" << std::endl;
      std::cout << "==============================================" << std::endl;
    }

#ifdef GRINS_USE_GRVY_TIMERS
  grvy_timer.EndTimer("Initialize Solver");

  // Attach GRVY timer to solver
  grins.attach_grvy_timer( &grvy_timer );
#endif

  grins.run();

#ifdef GRINS_USE_GRVY_TIMERS
  grvy_timer.Finalize();
 
  if( Parallel::Communicator_World.rank() == 0 ) grvy_timer.Summarize();
#endif

  return 0;
}