本文整理汇总了C++中GetPot::have_variable方法的典型用法代码示例。如果您正苦于以下问题:C++ GetPot::have_variable方法的具体用法?C++ GetPot::have_variable怎么用?C++ GetPot::have_variable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GetPot
的用法示例。
在下文中一共展示了GetPot::have_variable方法的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) );
}
}
示例2: 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;
}
示例3: 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");
}
}
示例4: 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;
}
示例5: 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);
}
}
示例6: check_dup_input_style
void AdaptiveTimeSteppingOptions::check_dup_input_style( const GetPot& input ) const
{
if( (input.have_variable("unsteady-solver/target_tolerance") &&
input.have_section("Strategies/AdaptiveTimeStepping/target_tolerance")) ||
(input.have_variable("unsteady-solver/upper_tolerance") &&
input.have_section("Strategies/AdaptiveTimeStepping/upper_tolerance")) ||
(input.have_variable("unsteady-solver/max_growth") &&
input.have_section("Strategies/AdaptiveTimeStepping/max_growth")) )
libmesh_error_msg("ERROR: Cannot use both old and new style of options for AdaptiveTimeSteppingOptions!");
}
示例7: 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;
}
示例8: AntiochChemistry
AntiochMixture::AntiochMixture( const GetPot& input )
: AntiochChemistry(input),
_reaction_set( new Antioch::ReactionSet<libMesh::Real>( (*_antioch_gas.get()) ) ),
_cea_mixture( new Antioch::CEAThermoMixture<libMesh::Real>( (*_antioch_gas.get()) ) )
{
if( !input.have_variable("Physics/Chemistry/chem_file") )
{
std::cerr << "Error: Must specify XML chemistry file to use Antioch." << std::endl;
libmesh_error();
}
std::string xml_filename = input( "Physics/Chemistry/chem_file", "DIE!");
bool verbose_read = input("screen-options/verbose_kinetics_read", false );
Antioch::read_reaction_set_data_xml<libMesh::Real>( xml_filename, verbose_read, *_reaction_set.get() );
std::string cea_data_filename = input( "Physics/Antioch/cea_data", "default" );
if( cea_data_filename == std::string("default") )
cea_data_filename = Antioch::DefaultInstallFilename::thermo_data();
Antioch::read_cea_mixture_data_ascii( *_cea_mixture.get(), cea_data_filename );
this->build_stat_mech_ref_correction();
return;
}
示例9: 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 );
}
}
示例10: input
ConstantPrandtlConductivity::ConstantPrandtlConductivity( const GetPot& input )
: _Pr( input("Materials/Conductivity/Pr", 0.0) )
{
if( !input.have_variable("Materials/Conductivity/Pr") )
{
std::cerr << "Error: Must specify Prandtl number for constant_prandtl conductivity model!" << std::endl;
libmesh_error();
}
return;
}
示例11: parse_deltat
double TimeSteppingParsing::parse_deltat( const GetPot& input )
{
double delta_t = 0.0;
if( input.have_variable("unsteady-solver/deltat") )
{
delta_t = input("unsteady-solver/deltat",0.0);
std::string warning = "WARNING: unsteady-solver/deltat is DEPRECATED!\n";
warning += " Please use SolverOptions/TimeStepping/delta_t to set delta_t.\n";
grins_warning(warning);
}
else if( input.have_variable("SolverOptions/TimeStepping/delta_t") )
delta_t = input("SolverOptions/TimeStepping/delta_t",0.0);
else
libmesh_error_msg("ERROR: Could not find valid entry for delta_t!");
return delta_t;
}
示例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;
}
示例13: if
ParsedConductivity::ParsedConductivity( const GetPot& input, const std::string& material )
: ParsedPropertyBase(),
ParameterUser("ParsedConductivity")
{
MaterialsParsing::duplicate_input_test(input,
"Materials/"+material+"/ThermalConductivity/value",
"Materials/Conductivity/k");
std::string conductivity_function;
// If we have the new version, we parse that
if( input.have_variable("Materials/"+material+"/ThermalConductivity/value") )
{
this->set_parameter(this->_func, input,
"Materials/"+material+"/ThermalConductivity/value",
"DIE!");
conductivity_function = input("Materials/"+material+"/ThermalConductivity/value",std::string("0"));
}
// If we have the old DEPRECATED version, use that
else if( input.have_variable("Materials/Conductivity/k") )
{
MaterialsParsing::dep_input_warning( "Materials/Conductivity/k",
"ThermalConductivity/value" );
this->set_parameter(this->_func, input,
"Materials/Conductivity/k",
"DIE!");
conductivity_function = input("Materials/Conductivity/k",std::string("0"));
}
// If we don't have either, that's an error
else
{
libmesh_error_msg("Error: Could not find either Materials/"+material+"/ThermalConductivity/value or Materials/Conductivity/k");
}
if( !this->check_func_nonzero(conductivity_function) )
{
libmesh_error_msg("ERROR: Detected '0' function for ParsedConductivity!");
}
}
示例14: input
ConstantSpecificHeat::ConstantSpecificHeat( const GetPot& input )
: _cp( input( "Materials/SpecificHeat/cp", 0.0 ) )
{
if( !input.have_variable("Materials/SpecificHeat/cp") )
{
std::cerr << "Error: Must specify cp value for constant specific heat model!" << std::endl;
libmesh_error();
}
return;
}
示例15: input
ConstantViscosity::ConstantViscosity( const GetPot& input )
: _mu( input( "Materials/Viscosity/mu", 0.0 ) )
{
if( !input.have_variable("Materials/Viscosity/mu") )
{
std::cerr << "Error: Must specify viscosity value for constant viscosity model!" << std::endl;
libmesh_error();
}
return;
}