コード例 #1
0
    //! Run the test on a given input file and calculated answer
    void run_test(const std::string filename, libMesh::Real calc_answer)
    {
      this->init_sim(filename);

      _sim->run();

      CPPUNIT_ASSERT_DOUBLES_EQUAL( calc_answer, _sim->get_qoi_value(0),libMesh::TOLERANCE  );
    }
コード例 #2
0
  GRINS::SharedPtr<Solver> InflatingSheetSolverFactory::build(const GetPot& input)
  {
    std::string solver_type = input("SolverOptions/solver_type", "DIE!");

    GRINS::SharedPtr<Solver> solver;  // Effectively NULL

    if( solver_type == std::string("pressure_continuation") )
      {
        solver.reset( new PressureContinuationSolver(input) );
      }
    else
      {
        solver = SolverFactory::build(input);
      }

    return solver;
  }
コード例 #3
0
    //! Initialize the GetPot and Simulation class objects
    void init_sim(const std::string & filename)
    {
      _input.reset(new GetPot(filename));

      const char * const argv = "unit_driver";
      GetPot empty_command_line( (const int)1,&argv );
      GRINS::SimulationBuilder sim_builder;

      _sim = new GRINS::Simulation(*_input,
                                    empty_command_line,
                                    sim_builder,
                                   *TestCommWorld );
    }
コード例 #4
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 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;
}
コード例 #5
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;
}