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


C++ GetPot::vector_variable_size方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: read_input_options

  void AverageNusseltNumber::read_input_options( const GetPot& input )
  {
    // Read thermal conductivity
    this->_k = input( "QoI/NusseltNumber/thermal_conductivity", -1.0 );

    if( this->_k < 0.0 )
      {
	std::cerr << "Error: thermal conductivity for AverageNusseltNumber must be positive." << std::endl
		  << "Found k = " << _k << std::endl;
	libmesh_error();
      }

    // Read boundary ids for which we want to compute
    int num_bcs =  input.vector_variable_size("QoI/NusseltNumber/bc_ids");

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

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

    this->_scaling = input( "QoI/NusseltNumber/scaling", 1.0 );

    return;
  }
开发者ID:ImageGuidedTherapyLab,项目名称:grins,代码行数:32,代码来源:average_nusselt_number.C

示例6: 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

示例7: 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

示例8: parse_var_info

  void SourceTermBase::parse_var_info( const GetPot& input )
  {
    if( !input.have_variable("Physics/"+this->_physics_name+"/Variables/names") )
      {
        libMesh::err << "Error: Must have at least one variable for source function." << std::endl
                     << "       Ensure that Physics/"+this->_physics_name+"/Variables/names is set." << std::endl;
        libmesh_error();
      }

    unsigned int n_vars = input.vector_variable_size("Physics/"+this->_physics_name+"/Variables/names");

    // Make sure we have consisent number of FE types and FE orders
    /*! \todo In the future, after refactoring Variable parsing, we should be
              able get the FE type and order information from there. */
    unsigned int n_fe_types = input.vector_variable_size("Physics/"+this->_physics_name+"/Variables/FE_types");

    unsigned int n_fe_orders = input.vector_variable_size("Physics/"+this->_physics_name+"/Variables/FE_orders");

    if( n_fe_types != n_vars )
      {
        libMesh::err << "Error: Must have matching number of variable names and FE types." << std::endl
                     << "       Found " << n_fe_types << " FE types and " << n_vars << " variables." << std::endl
                     << "       Ensure Physics/"+this->_physics_name+"/Variables/FE_types is consistent." << std::endl;
        libmesh_error();
      }

    if( n_fe_orders != n_vars )
      {
        libMesh::err << "Error: Must have matching number of variable names and FE orders." << std::endl
                     << "       Found " << n_fe_orders << " FE orders and " << n_vars << " variables." << std::endl
                     << "       Ensure Physics/"+this->_physics_name+"/Variables/FE_orders is consistent." << std::endl;
        libmesh_error();
      }

    _var_names.reserve(n_vars);
    _var_FE.reserve(n_vars);
    _var_order.reserve(n_vars);
    for( unsigned int v = 0; v < n_vars; v++ )
      {
        _var_names.push_back( input("Physics/"+this->_physics_name+"/Variables/names", "DIE!", v) );
        _var_FE.push_back( libMesh::Utility::string_to_enum<GRINSEnums::FEFamily>(input("Physics/"+this->_physics_name+"/Variables/FE_types", "DIE!", v)) );
        _var_order.push_back( libMesh::Utility::string_to_enum<GRINSEnums::Order>(input("Physics/"+this->_physics_name+"/Variables/FE_orders", "DIE!", v)) );
      }

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

示例9: names

  PostProcessedQuantities<NumericType>::PostProcessedQuantities( const GetPot& input )
    : libMesh::FEMFunctionBase<NumericType>(),
      _prev_point(1.0e15,0.0,0.0) //Initialize to an absurd value
  {
    this->build_name_map();

    /* Parse the quantities requested for postprocessing and cache the 
       corresponding enum value */
    unsigned int n_quantities = input.vector_variable_size( "vis-options/output_vars" );
    std::vector<std::string> names(n_quantities);
    _quantities.resize(n_quantities);

    for( unsigned int n = 0; n < n_quantities; n++ )
      {
	names[n] = input("vis-options/output_vars", "DIE!", n);
	
	typename std::map<std::string, unsigned int>::const_iterator name_it = 
	  _quantity_name_map.find(names[n]);
	
	if( name_it != _quantity_name_map.end() )
	  {
	    _quantities[n] = name_it->second;
	  }
	else
	  {
	    std::cerr << "Error: Invalid name " << names[n] << " for PostProcessedQuantity." 
		      << std::endl;
	    libmesh_error();
	  }

	// Need to cache species names if needed.
	if( names[n] == std::string("mole_fractions") )
	  {
	    unsigned int species_size = input.vector_variable_size( "Physics/Chemistry/species" );
	    _species_names.resize(species_size);
	    
	    for( unsigned int s = 0; s < species_size; s++ )
	      {
		_species_names[s] = input("Physics/Chemistry/species","DIE!",s);
	      }
	  }
      }

    return;
  }
开发者ID:SylvainPlessis,项目名称:grins,代码行数:45,代码来源:postprocessed_quantities.C

示例10: dataFile

void
BCInterfaceData::readParameters( const GetPot& dataFile, const char* parameters )
{
    UInt parametersSize = dataFile.vector_variable_size( parameters );

    M_parameters.resize( parametersSize );
    for ( UInt j( 0 ); j < parametersSize; ++j )
        M_parameters[j] = dataFile( parameters, 0, j );
}
开发者ID:nuraiman,项目名称:lifev,代码行数:9,代码来源:BCInterfaceData.cpp

示例11: build_periodic_bc

  void OldStyleBCBuilder::build_periodic_bc( const GetPot& input,
                                             const std::string& section,
                                             BoundaryID bc_id,
                                             libMesh::DofMap& dof_map )
  {
    std::string wall_input = section+"/periodic_wall_";
    wall_input += StringUtilities::T_to_string<BoundaryID>(bc_id);

    if( input.have_variable(wall_input) )
      {
        libMesh::boundary_id_type invalid_bid =
          std::numeric_limits<libMesh::boundary_id_type>::max();

        libMesh::boundary_id_type slave_id = invalid_bid;
        libMesh::boundary_id_type master_id = invalid_bid;

        if( input.vector_variable_size(wall_input) != 2 )
          libmesh_error_msg("ERROR: "+wall_input+" must have only 2 components!");

        master_id = bc_id;

        if( input(wall_input,invalid_bid,0) == bc_id )
          slave_id = input(wall_input,invalid_bid,1);
        else
          slave_id = input(wall_input,invalid_bid,0);

        std::string offset_input = section+"/periodic_offset_";
        offset_input += StringUtilities::T_to_string<BoundaryID>(bc_id);

        if( !input.have_variable(offset_input) )
          libmesh_error_msg("ERROR: Could not find "+offset_input+"!");

        unsigned int n_comps = input.vector_variable_size(offset_input);

        libMesh::Real invalid_real = std::numeric_limits<libMesh::Real>::max();

        libMesh::RealVectorValue offset_vector;
        for( unsigned int i = 0; i < n_comps; i++ )
          offset_vector(i) = input(offset_input,invalid_real,i);

        this->add_periodic_bc_to_dofmap( master_id, slave_id,
                                         offset_vector, dof_map );
      }
  }
开发者ID:coreymbryant,项目名称:grins,代码行数:44,代码来源:old_style_bc_builder.C

示例12: 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

示例13: init_bc_types

  void HeatTransferBCHandling::init_bc_types( const BoundaryID bc_id, 
					      const std::string& bc_id_string, 
					      const int bc_type, 
					      const std::string& bc_vars, 
					      const std::string& bc_value, 
					      const GetPot& input )
  {
    switch(bc_type)
      {
      case(ISOTHERMAL_WALL):
	{
	  this->set_dirichlet_bc_type( bc_id, bc_type );

	  this->set_dirichlet_bc_value( bc_id, input("Physics/"+_physics_name+"/T_wall_"+bc_id_string, 0.0 ) );
	}
	break;
      
      case(ADIABATIC_WALL):
	{
	  this->set_neumann_bc_type( bc_id, bc_type );
	}
	break;
      
      case(PRESCRIBED_HEAT_FLUX):
	{
	  this->set_neumann_bc_type( bc_id, bc_type );
	
	  libMesh::RealGradient q_in;
	
	  int num_q_components = input.vector_variable_size("Physics/"+_physics_name+"/q_wall_"+bc_id_string);
	
	  for( int i = 0; i < num_q_components; i++ )
	    {
	      q_in(i) = input("Physics/"+_physics_name+"/q_wall_"+bc_id_string, 0.0, i );
	    }

	  this->set_neumann_bc_value( bc_id, q_in );
	}
	break;
      case(GENERAL_HEAT_FLUX):
	{
	  this->set_neumann_bc_type( bc_id, bc_type );
	}
	break;
      default:
	{
	  // Call base class to detect any physics-common boundary conditions
	  BCHandlingBase::init_bc_types( bc_id, bc_id_string, bc_type,
                                         bc_vars, bc_value, input );
	}
      
      }// End switch(bc_type)

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

示例14: dataFile

// ===================================================
// Private Methods
// ===================================================
void
BCInterfaceData1D::readResistance ( const GetPot& dataFile, const char* resistance )
{
    UInt resistanceSize = dataFile.vector_variable_size ( resistance );

    M_resistance.resize ( resistanceSize );
    for ( UInt j ( 0 ); j < resistanceSize; ++j )
    {
        M_resistance[j] = dataFile ( resistance, 0, j );
    }
}
开发者ID:Danniel-UCAS,项目名称:lifev,代码行数:14,代码来源:BCInterfaceData1D.cpp

示例15: read_input_options

  void Physics::read_input_options( const GetPot& input )
  {
    int num_ids = input.vector_variable_size( "Physics/"+this->_physics_name+"/enabled_subdomains" );

    for( int i = 0; i < num_ids; i++ )
      {
	libMesh::subdomain_id_type dumvar = input( "Physics/"+this->_physics_name+"/enabled_subdomains", -1, i );
	_enabled_subdomains.insert( dumvar );
      }

    return;
  }
开发者ID:DominicWade,项目名称:grins,代码行数:12,代码来源:physics.C


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