当前位置: 首页>>代码示例>>C++>>正文


C++ GetPot类代码示例

本文整理汇总了C++中GetPot的典型用法代码示例。如果您正苦于以下问题:C++ GetPot类的具体用法?C++ GetPot怎么用?C++ GetPot使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了GetPot类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: parse_options

  void AdaptiveTimeSteppingOptions::parse_options(const GetPot& input, const std::string& section)
  {
    // If the user set the target tolerance, for them to set the other values too
    if( input.have_variable(section+"/target_tolerance") )
      {
        if( !input.have_variable(section+"/upper_tolerance") )
          libmesh_error_msg("ERROR: Must specify "+section+"/upper_tolerance for adaptive time stepping!");

        if( !input.have_variable(section+"/max_growth") )
          libmesh_error_msg("ERROR: Must specify "+section+"/max_growth for adaptive time stepping!");
      }

    _target_tolerance = input(section+"/target_tolerance", 0.0 );
    _upper_tolerance = input(section+"/upper_tolerance", 0.0 );
    _max_growth = input(section+"/max_growth", 0.0 );

    // parse component_norm
    const unsigned int n_component_norm =
      input.vector_variable_size(section+"/component_norm");

    for (unsigned int i=0; i != n_component_norm; ++i)
      {
        const std::string current_norm = input(section+"/component_norm", std::string("L2"), i);
        _component_norm.set_type(i, libMesh::Utility::string_to_enum<libMesh::FEMNormType>(current_norm) );
      }
  }
开发者ID:tradowsk,项目名称:grins,代码行数:26,代码来源:adaptive_time_stepping_options.C

示例2: is_transient

  bool SolverParsing::is_transient( const GetPot& input )
  {
    // Can't specify both old and new version
    SolverParsing::dup_solver_option_check(input,
                                           "unsteady-solver/transient",
                                           "SolverOptions/TimeStepping/solver_type");

    bool transient = false;

    if( input.have_variable("unsteady-solver/transient") )
      {
        transient = input("unsteady-solver/transient",false);

        std::string warning = "WARNING: unsteady-solver/transient is DEPRECATED!\n";
        warning += "        Please use SolverOptions/TimeStepping/solver_type to specify time stepping solver.\n";
        grins_warning(warning);
      }

    // In the new version, we set the solver type so we just need to
    // check if the variable is present. Solver class will figure
    // out the type.
    if( input.have_variable("SolverOptions/TimeStepping/solver_type") )
      transient = true;

    return transient;
  }
开发者ID:coreymbryant,项目名称:grins,代码行数:26,代码来源:solver_parsing.C

示例3: SteadySolver

  PressureContinuationSolver::PressureContinuationSolver( const GetPot& input )
    : SteadySolver(input)
  {
    if( !input.have_variable("SolverOptions/PressureContinuation/final_pressure") )
      {
        std::cerr << "Error: Did not find final_pressure value for PressureContinuationSolver" << std::endl
                  << "       Must specify SolverOptions/PressureContinuation/final_pressure" << std::endl;
        libmesh_error();
      }
    libMesh::Real final_pressure_value = input("SolverOptions/PressureContinuation/final_pressure", 0.0);

    libMesh::Real initial_pressure_value = input("SolverOptions/PressureContinuation/initial_pressure", 0.0);



    if( !input.have_variable("SolverOptions/PressureContinuation/n_increments") )
      {
        std::cerr << "Error: Did not find n_increments value for PressureContinuationSolver" << std::endl
                  << "       Must specify SolverOptions/PressureContinuation/n_increments" << std::endl;
        libmesh_error();
      }
    unsigned int n_increments = input("SolverOptions/PressureContinuation/n_increments", 1);

    _pressure_values.resize(n_increments);

    libMesh::Real increment = (final_pressure_value - initial_pressure_value)/n_increments;

    for( unsigned int i = 0; i < n_increments; i++ )
      {
        _pressure_values[i] = (i+1)*increment + initial_pressure_value;
      }

    return;
  }
开发者ID:gmeer,项目名称:grins,代码行数:34,代码来源:pressure_continuation_solver.C

示例4: if

  ConstantSpecificHeat::ConstantSpecificHeat( const GetPot& input,
                                              const std::string& material )
    : ParameterUser("ConstantSpecificHeat"),
      _cp(0.0)
  {
    // It's an error to have both the old and new version
    MaterialsParsing::duplicate_input_test(input,
                                           "Materials/"+material+"/SpecificHeat/value",
                                           "Materials/SpecificHeat/cp");

    // If we have the "new" version, then parse it
    if( input.have_variable("Materials/"+material+"/SpecificHeat/value") )
      {
        this->set_parameter
          (_cp, input, "Materials/"+material+"/SpecificHeat/value", _cp);
      }
    // If instead we have the old version, use that.
    else if( input.have_variable("Materials/SpecificHeat/cp") )
      {
        MaterialsParsing::dep_input_warning( "Materials/SpecificHeat/cp",
                                             "SpecificHeat/value" );

        this->set_parameter
          (_cp, input, "Materials/SpecificHeat/cp", _cp);
      }
    else
      {
        libmesh_error_msg("ERROR: Could not find valid input for ConstantSpecificHeat! Please set Materials/"+material+"/SpecificHeat/value");
      }
  }
开发者ID:coreymbryant,项目名称:grins,代码行数:30,代码来源:constant_specific_heat.C

示例5: check_and_get_inputfile

  std::string Runner::check_and_get_inputfile(int argc, char* argv[], GetPot & command_line)
  {
    if( argc < 2 )
      {
        std::stringstream error_msg;
        error_msg << "ERROR: Found only 1 command line argument, but was expecting an inputfile name!"
                  << std::endl
                  << "       Please specify the name of the input file on the command line as the first" << std::endl
                  << "       command line argument or using the '--input <filename>' option." << std::endl;
        libmesh_error_msg(error_msg.str());
      }

    std::string inputfile_name;
    if( command_line.search("--input") )
      inputfile_name = command_line.next(std::string("DIE!"));
    else
      inputfile_name = argv[1];

    std::ifstream i(inputfile_name.c_str());
    if (!i)
      {
        std::string error_msg = "Error: Could not read from input file "+inputfile_name+"!\n";
        libmesh_error_msg(error_msg);
      }

    return inputfile_name;
  }
开发者ID:tradowsk,项目名称:grins,代码行数:27,代码来源:runner.C

示例6: read_input_options

  void MultiphysicsSystem::read_input_options( const GetPot& input )
  {
    // Cache this for building boundary condition later
    _input = &input;

    // Read options for MultiphysicsSystem first
    this->verify_analytic_jacobians = input("linear-nonlinear-solver/verify_analytic_jacobians", 0.0 );
    this->print_solution_norms = input("screen-options/print_solution_norms", false );
    this->print_solutions = input("screen-options/print_solutions", false );
    this->print_residual_norms = input("screen-options/print_residual_norms", false );

    // backwards compatibility with old config files.
    /*! \todo Remove old print_residual nomenclature */
    this->print_residuals = input("screen-options/print_residual", false );
    if (this->print_residuals)
      libmesh_deprecated();

    this->print_residuals = input("screen-options/print_residuals", this->print_residuals );
    this->print_jacobian_norms = input("screen-options/print_jacobian_norms", false );
    this->print_jacobians = input("screen-options/print_jacobians", false );
    this->print_element_solutions = input("screen-options/print_element_solutions", false );
    this->print_element_residuals = input("screen-options/print_element_residuals", false );
    this->print_element_jacobians = input("screen-options/print_element_jacobians", false );

    _use_numerical_jacobians_only = input("linear-nonlinear-solver/use_numerical_jacobians_only", false );

    numerical_jacobian_h =
      input("linear-nonlinear-solver/numerical_jacobian_h",
            numerical_jacobian_h);

    const unsigned int n_numerical_jacobian_h_values =
      input.vector_variable_size
        ("linear-nonlinear-solver/numerical_jacobian_h_values");

    if (n_numerical_jacobian_h_values !=
        input.vector_variable_size
          ("linear-nonlinear-solver/numerical_jacobian_h_variables"))
      {
        std::cerr << "Error: found " << n_numerical_jacobian_h_values
                  << " numerical_jacobian_h_values" << std::endl;
        std::cerr << "  but "
                  << input.vector_variable_size
                       ("linear-nonlinear-solver/numerical_jacobian_h_variables")
                << " numerical_jacobian_h_variables" << std::endl;
        libmesh_error();
      }

    _numerical_jacobian_h_variables.resize(n_numerical_jacobian_h_values);
    _numerical_jacobian_h_values.resize(n_numerical_jacobian_h_values);
    for (unsigned int i=0; i != n_numerical_jacobian_h_values; ++i)
      {
        _numerical_jacobian_h_variables[i] =
          input("linear-nonlinear-solver/numerical_jacobian_h_variables",
                "", i);
        _numerical_jacobian_h_values[i] =
          input("linear-nonlinear-solver/numerical_jacobian_h_values",
                libMesh::Real(0), i);
      }
  }
开发者ID:nicholasmalaya,项目名称:grins,代码行数:59,代码来源:multiphysics_sys.C

示例7: read_ic_data

  void ICHandlingBase::read_ic_data( const GetPot& input, const std::string& id_str,
                                     const std::string& ic_str,
                                     const std::string& var_str,
                                     const std::string& value_str)
  {
    int num_ids = input.vector_variable_size(id_str);
    int num_ics = input.vector_variable_size(ic_str);
    int num_vars = input.vector_variable_size(var_str);
    int num_values = input.vector_variable_size(value_str);

    if( num_ids != num_ics )
      {
        std::cerr << "Error: number of subdomain ids " << num_ids
                  << "must equal number of initial condition types " << num_ics
                  << std::endl;
        libmesh_error();
      }

    if( num_ids != num_vars )
      {
        std::cerr << "Error: number of subdomain ids " << num_ids
                  << "must equal number of variable name lists " << num_vars
                  << std::endl;
        libmesh_error();
      }

    if( num_ids != num_values )
      {
        std::cerr << "Error: number of subdomain ids " << num_ids
                  << "must equal number of initial condition values " << num_values
                  << std::endl;
        libmesh_error();
      }

    if( num_ids > 1 )
      {
        std::cerr << "Error: GRINS does not yet support per-subdomain initial conditions" << std::endl;
        libmesh_not_implemented();
      }

    for( int i = 0; i < num_ids; i++ )
      {
        int ic_id = input(id_str, -1, i );
        std::string ic_type_in = input(ic_str, "NULL", i );
        std::string ic_value_in = input(value_str, "NULL", i );
        std::string ic_vars_in = input(var_str, "NULL", i );

        int ic_type = this->string_to_int( ic_type_in );

        std::stringstream ss;
        ss << ic_id;
        std::string ic_id_string = ss.str();

        this->init_ic_types( ic_id, ic_id_string, ic_type, ic_vars_in, ic_value_in, input );
      }

    return;
  }
开发者ID:tradowsk,项目名称:grins,代码行数:58,代码来源:ic_handling_base.C

示例8: dup_solver_option_check

 void SolverParsing::dup_solver_option_check( const GetPot& input,
                                              const std::string& option1,
                                              const std::string& option2 )
 {
   // Can't specify both old and new version
   if( input.have_variable(option1) && input.have_variable(option2) )
     {
       libmesh_error_msg("ERROR: Cannot specify both "+option1+" and "+option2);
     }
 }
开发者ID:coreymbryant,项目名称:grins,代码行数:10,代码来源:solver_parsing.C

示例9: if

  void VelocityPenalty<Mu>::register_postprocessing_vars( const GetPot& input,
                                                          PostProcessedQuantities<libMesh::Real>& postprocessing )
  {
    std::string section = "Physics/"+this->_physics_name+"/output_vars";

    std::string vel_penalty = "vel_penalty";
    if (this->_physics_name == "VelocityPenalty2")
      vel_penalty += '2';

    if (this->_physics_name == "VelocityPenalty3")
      vel_penalty += '3';

    if( input.have_variable(section) )
      {
        unsigned int n_vars = input.vector_variable_size(section);

        for( unsigned int v = 0; v < n_vars; v++ )
          {
            std::string name = input(section,"DIE!",v);

            if( name == std::string("velocity_penalty") )
              {
                _velocity_penalty_x_index =
                  postprocessing.register_quantity( vel_penalty+"_x" );

                _velocity_penalty_y_index =
                  postprocessing.register_quantity( vel_penalty+"_y" );

                _velocity_penalty_z_index =
                  postprocessing.register_quantity( vel_penalty+"_z" );
              }
            else if( name == std::string("velocity_penalty_base") )
              {
                _velocity_penalty_base_x_index =
                  postprocessing.register_quantity( vel_penalty+"_base_x" );

                _velocity_penalty_base_y_index =
                  postprocessing.register_quantity( vel_penalty+"_base_y" );

                _velocity_penalty_base_z_index =
                  postprocessing.register_quantity( vel_penalty+"_base_z" );
              }
            else
              {
                std::cerr << "Error: Invalue output_vars value for "+this->_physics_name << std::endl
                          << "       Found " << name << std::endl
                          << "       Acceptable values are: velocity_penalty" << std::endl
                          << "                              velocity_penalty_base" << std::endl;
                libmesh_error();
              }
          }
      }

    return;
  }
开发者ID:gdmcbain,项目名称:grins,代码行数:55,代码来源:velocity_penalty.C

示例10: assert_argument

T assert_argument (GetPot &cl,
                   const std::string &argname,
                   const char        *progname,
                   const T&          defaultarg)
{
  if(!cl.search(argname))
    {
      libMesh::err << ("No " + argname + " argument found!") << std::endl;
      usage_error(progname);
    }
  return cl.next(defaultarg);
}
开发者ID:karpeev,项目名称:libmesh,代码行数:12,代码来源:projection.C

示例11: init_params

  void Simulation::init_params( const GetPot& input,
                                SimulationBuilder& /*sim_builder*/ )
  {
    unsigned int n_adjoint_parameters =
      input.vector_variable_size("QoI/adjoint_sensitivity_parameters");

    unsigned int n_forward_parameters =
      input.vector_variable_size("QoI/forward_sensitivity_parameters");

    // If the user actually asks for parameter sensitivities, then we
    // set up the parameter vectors to use.
    if ( n_adjoint_parameters )
      {
        // If we're doing adjoint sensitivities, dq/dp only makes
        // sense if we have q
        CompositeQoI* qoi =
          libMesh::cast_ptr<CompositeQoI*>
          (this->_multiphysics_system->get_qoi());

        if (!qoi)
          {
            std::cout <<
              "Error: adjoint_sensitivity_parameters are specified but\n"
                      << "no QoIs have been specified.\n" << std::endl;
            libmesh_error();
          }

        _adjoint_parameters.initialize
          (input, "QoI/adjoint_sensitivity_parameters",
           *this->_multiphysics_system, qoi);
      }

    if ( n_forward_parameters )
      {
        // If we're doing forward sensitivities, du/dp can make
        // sense even with no q defined
        CompositeQoI* qoi =
          dynamic_cast<CompositeQoI*>
          (this->_multiphysics_system->get_qoi());

        // dynamic_cast returns NULL if our QoI isn't a CompositeQoI;
        // i.e. if there were no QoIs that made us bother setting up
        // the CompositeQoI object.  Passing NULL tells
        // ParameterManager not to bother asking for qoi registration
        // of parameters.

        _forward_parameters.initialize
          (input, "QoI/forward_sensitivity_parameters",
           *this->_multiphysics_system, qoi);
      }
  }
开发者ID:tradowsk,项目名称:grins,代码行数:51,代码来源:simulation.C

示例12: read_input_options

  void HookesLaw::read_input_options(const GetPot& input)
  {
    // We'd better have either Lam\'{e} constants or E and nu
    if( ( !input.have_variable("Physics/HookesLaw/lambda") || 
          !input.have_variable("Physics/HookesLaw/mu") ) &&
        ( !input.have_variable("Physics/HookesLaw/E") || 
          !input.have_variable("Physics/HookesLaw/nu") ) )
      {
        std::cerr << "Error: Must specify either Lame constants lambda and mu or" << std::endl
                  << "       Young's modulus and Poisson's ratio." << std::endl;
        libmesh_error();
      }

    if( input.have_variable("Physics/HookesLaw/lambda") )
      this->set_parameter
        (_lambda, input, "Physics/HookesLaw/lambda", 0.0);
    
    if( input.have_variable("Physics/HookesLaw/mu") )
      this->set_parameter
        (_mu, input, "Physics/HookesLaw/mu", 0.0);
        
    if( input.have_variable("Physics/HookesLaw/E") && 
        input.have_variable("Physics/HookesLaw/nu") )
      {
        // FIXME - we'll need a special accessor to give parameter
        // access to these
        libMesh::Real E  = input("Physics/HookesLaw/E", 0.0);
        libMesh::Real nu = input("Physics/HookesLaw/nu", 0.0);
        _lambda = nu*E/( (1+nu)*(1-2*nu) );
        _mu = E/(2*(1+nu));
      }

    return;
  }
开发者ID:coreymbryant,项目名称:grins,代码行数:34,代码来源:hookes_law.C

示例13: check_for_flux

  void NeumannBCFactoryAbstract::check_for_flux( const GetPot& input, const std::string& flux_input,
                                                 const std::vector<std::string>& var_names )
  {
    if( !input.have_variable(flux_input) )
      libmesh_error_msg("ERROR: Could not find input specification for "+flux_input+"!");

    unsigned int flux_size = input.vector_variable_size(flux_input);
    if( flux_size != var_names.size() )
      {
        std::string error_msg = "ERROR: Mismatch in size between flux input and variables size!\n";
        error_msg += "       Found flux size      = "+StringUtilities::T_to_string<unsigned int>(flux_size)+"\n";
        error_msg += "       Found variables size = "+StringUtilities::T_to_string<unsigned int>(var_names.size())+"\n";
        libmesh_error_msg(error_msg);
      }
  }
开发者ID:coreymbryant,项目名称:grins,代码行数:15,代码来源:neumann_bc_factory_abstract.C

示例14: check_qoi_physics_consistency

  void QoIFactory::check_qoi_physics_consistency( const GetPot& input, 
						  const std::string& qoi_name )
  {
    int num_physics =  input.vector_variable_size("Physics/enabled_physics");

    // This should be checked other places, but let's be double sure.
    libmesh_assert(num_physics > 0);
  
    std::set<std::string> requested_physics;
    std::set<std::string> required_physics;

    // Build Physics name set
    for( int i = 0; i < num_physics; i++ )
      {
	requested_physics.insert( input("Physics/enabled_physics", "NULL", i ) );
      }
  
    /* If it's Nusselt, we'd better have HeatTransfer or LowMachNavierStokes. 
       HeatTransfer implicitly requires fluids, so no need to check for those. `*/
    if( qoi_name == avg_nusselt )
      {
	required_physics.insert(heat_transfer);
	required_physics.insert(low_mach_navier_stokes);
	this->consistency_helper( requested_physics, required_physics, qoi_name );
      }
      
    return;
  }
开发者ID:gdmcbain,项目名称:grins,代码行数:28,代码来源:qoi_factory.C

示例15: init

  void ParsedBoundaryQoI::init( const GetPot& input, const MultiphysicsSystem& system )
  {
    // Read boundary ids on which we want to compute qoi
    int num_bcs =  input.vector_variable_size("QoI/ParsedBoundary/bc_ids");

    if( num_bcs <= 0 )
      {
        std::cerr << "Error: Must specify at least one boundary id to compute"
                  << " parsed boundary QoI." << std::endl
                  << "Found: " << num_bcs << std::endl;
        libmesh_error();
      }

    for( int i = 0; i < num_bcs; i++ )
      {
        _bc_ids.insert( input("QoI/ParsedBoundary/bc_ids", -1, i ) );
      }

    std::string qoi_functional_string =
      input("QoI/ParsedBoundary/qoi_functional", std::string("0"));

    if (qoi_functional_string == "0")
      libmesh_error_msg("Error! Zero ParsedBoundaryQoI specified!" <<
                        std::endl);

    this->qoi_functional.reset
      (new libMesh::ParsedFEMFunction<libMesh::Number>
       (system, qoi_functional_string));
  }
开发者ID:jcamata,项目名称:grins,代码行数:29,代码来源:parsed_boundary_qoi.C


注:本文中的GetPot类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。