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
0
  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;
  }
示例#3
0
  ElasticMembraneConstantPressure::ElasticMembraneConstantPressure( const GRINS::PhysicsName& physics_name, const GetPot& input )
    : ElasticMembraneAbstract(physics_name,input),
      _pressure(0.0)
  {
    if( !input.have_variable("Physics/"+physics_name+"/pressure") )
      {
        std::cerr << "Error: Must input pressure for "+physics_name+"." << std::endl
                  << "       Please set Physics/"+physics_name+"/pressure." << std::endl;
        libmesh_error();
      }

    this->set_parameter
      (_pressure, input, "Physics/"+physics_name+"/pressure", _pressure );

    // If the user specified enabled subdomains in this Physics section,
    // that's an error; we're slave to ElasticMembrane.
    if( input.have_variable("Physics/"+PhysicsNaming::elastic_membrane_constant_pressure()+"/enabled_subdomains" ) )
      libmesh_error_msg("ERROR: Cannot specify subdomains for "
                        +PhysicsNaming::elastic_membrane_constant_pressure()
                        +"! Must specify subdomains through "
                        +PhysicsNaming::elastic_membrane()+".");

    this->parse_enabled_subdomains(input,PhysicsNaming::elastic_membrane());

    if( this->_disp_vars.dim() != 3 )
      libmesh_error_msg("ERROR: ElasticMembraneConstantPressure only valid for three dimensions! Make sure you have three components in your Displacement type variable.");
  }
  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;
  }
  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");
      }
  }
示例#6
0
文件: runner.C 项目: tradowsk/grins
  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;
  }
示例#7
0
  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);
      }
  }
示例#8
0
  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;
  }
示例#9
0
 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);
     }
 }
示例#10
0
  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;
  }
示例#11
0
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);
}
示例#12
0
  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);
      }
  }
示例#13
0
  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;
  }
  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);
      }
  }
示例#15
0
  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;
  }
示例#16
0
  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));
  }
示例#17
0
  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;
  }
示例#18
0
  void ViscosityBase::check_input_consistency( const GetPot& input, const std::string& material ) const
  {
    // We can't have both the materials version and the old versions
    MaterialsParsing::duplicate_input_test(input,
                                           "Materials/"+material+"/Viscosity/value",
                                           "Materials/Viscosity/mu" );

    // If the material section exists, but not the variable, this is an error
    if( input.have_section("Materials/"+material+"/Viscosity") &&
        !input.have_variable("Materials/"+material+"/Viscosity/value") )
      {
        libmesh_error_msg("Error: Found section Materials/"+material+"/Viscosity, but not variable value.");
      }

    return;
  }
  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;
  }
示例#20
0
bool
BCInterfaceData::isBase( const GetPot& dataFile, const char* base, std::string& baseString )
{
    baseString = dataFile( base, " " );

    return dataFile.checkVariable( base );
}
示例#21
0
  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;
  }
  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;
  }
示例#23
0
  void testVariables()
  {
    CPPUNIT_ASSERT( input.have_variable("Section1/var1") );
    Real var1 = input("Section1/var1", 1.0);
    CPPUNIT_ASSERT_EQUAL( var1, Real(5));

    CPPUNIT_ASSERT( input.have_variable("Section1/SubSection1/var2") );
    std::string var2 = input("Section1/SubSection1/var2", "DIE!");
    CPPUNIT_ASSERT_EQUAL( var2, std::string("blah") );

    // This variable is commented out in the input file so we shouldn't find it.
    CPPUNIT_ASSERT( !input.have_variable("Section2/var3") );
    int var3 = input("Section2/var3", 314);
    CPPUNIT_ASSERT_EQUAL( var3, 314 );

    CPPUNIT_ASSERT( input.have_variable("Section2/Subsection2/var4") );
    bool var4 = input("Section2/Subsection2/var4", true);
    CPPUNIT_ASSERT_EQUAL( var4, false );

    CPPUNIT_ASSERT( input.have_variable("Section2/Subsection2/Subsection3/var5") );
    Real var5 = input("Section2/Subsection2/Subsection3/var5", 3.1415);
    CPPUNIT_ASSERT_EQUAL( var5, Real(6.02e23));

    CPPUNIT_ASSERT( input.have_variable("Section2/Subsection4/var6") );
    unsigned int var6 = input("Section2/Subsection4/var6", 21);
    CPPUNIT_ASSERT_EQUAL( var6, (unsigned int)42 );

    // We didn't use Section3/unused_var so it should be a UFO
    std::vector<std::string> ufos = input.unidentified_variables();
    CPPUNIT_ASSERT_EQUAL( ufos.size(),  (std::vector<std::string>::size_type)1 );
    CPPUNIT_ASSERT_EQUAL( ufos[0], std::string("Section3/unused_var") );
  }
示例#24
0
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 );
}
示例#25
0
  bool BCBuilder::is_new_bc_input_style( const GetPot& input )
  {
    bool new_style = false;

    if( input.have_section(BoundaryConditionNames::bc_section()) )
      new_style = true;

    return new_style;
  }
示例#26
0
  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 );
      }
  }
示例#27
0
  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;
  }
示例#28
0
  std::vector<std::string> VariableFactoryBasic<VariableType>::parse_var_names( const GetPot& input,
                                                                                const std::string& var_section )
  {
    std::vector<std::string> var_names;

    std::string input_sec = var_section+"/names";

    // Make sure the names are present
    if( !input.have_variable(input_sec) )
      libmesh_error_msg("ERROR: Could not find input parameter "+input_sec);

    unsigned int n_names = input.vector_variable_size(input_sec);

    var_names.resize(n_names);
    for( unsigned int i = 0; i < n_names; i++ )
      var_names[i] = input(input_sec,std::string("DIE!"),i);

    return var_names;
  }
 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;
 }
  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;
  }