예제 #1
0
  void VariableBuilder::add_vars_to_system( MultiphysicsSystem& system,
                                            const std::vector<std::string>& var_names,
                                            const std::string& fe_family,
                                            const std::string& order,
                                            std::vector<VariableIndex>& var_indices,
                                            const std::set<libMesh::subdomain_id_type>& subdomain_ids )
  {
    const unsigned int n_vars = var_names.size();

    // Setup var_indices
    libmesh_assert( var_indices.empty() );
    var_indices.resize(n_vars);

    if( subdomain_ids.empty() )
      for( unsigned int v = 0; v < n_vars; v++ )
        var_indices[v] = system.add_variable( var_names[v],
                                              libMesh::Utility::string_to_enum<GRINSEnums::Order>(order),
                                              libMesh::Utility::string_to_enum<GRINSEnums::FEFamily>(fe_family) );

    else
      for( unsigned int v = 0; v < n_vars; v++ )
        var_indices[v] = system.add_variable( var_names[v],
                                              libMesh::Utility::string_to_enum<GRINSEnums::Order>(order),
                                              libMesh::Utility::string_to_enum<GRINSEnums::FEFamily>(fe_family),
                                              &subdomain_ids );
  }
  void AverageNusseltNumber::init( const GetPot& input, const MultiphysicsSystem& system )
  {
    // Grab temperature variable index
    std::string T_var_name = input("Physics/VariableNames/Temperature",
				   T_var_name_default);

    this->_T_var = system.variable_number(T_var_name);
    return;
  }
예제 #3
0
  void Vorticity::init( const GetPot& input, const MultiphysicsSystem& system )
  {
    // Grab velocity variable indices
    std::string u_var_name = input("Physics/VariableNames/u_velocity", u_var_name_default);
    std::string v_var_name = input("Physics/VariableNames/v_velocity", v_var_name_default);
    this->_u_var = system.variable_number(u_var_name);
    this->_v_var = system.variable_number(v_var_name);

    return;
  }
 void PrescribedVectorValueDirichletOldStyleBCFactory::add_funcs( const GetPot& input,
                                                                  MultiphysicsSystem& system,
                                                                  const std::string& input_string,
                                                                  const std::vector<std::string>& var_names,
                                                                  libMesh::CompositeFunction<libMesh::Number>& composite_func ) const
 {
   for( unsigned int n = 0; n < var_names.size(); n++ )
     {
       std::vector<VariableIndex> dbc_vars(1,system.variable_number(var_names[n]));
       libMesh::Number value = input(input_string, 0.0, n);
       libMesh::ConstFunction<libMesh::Number> const_func(value);
       composite_func.attach_subfunction(const_func, dbc_vars);
     }
 }
예제 #5
0
  void AverageNusseltNumber::init
    (const GetPot& input,
     const MultiphysicsSystem& system,
     unsigned int /*qoi_num*/ )
  {
    this->set_parameter
      ( _k, input, "QoI/NusseltNumber/thermal_conductivity", -1.0 );

    this->set_parameter
      ( _scaling, input, "QoI/NusseltNumber/scaling", 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 ) );
      }

    // Grab temperature variable index
    std::string T_var_name = input( "Physics/VariableNames/Temperature",
				    T_var_name_default );

    this->_T_var = system.variable_number(T_var_name);

    return;
  }
예제 #6
0
  void ParameterManager::initialize
    ( const GetPot& input,
      const std::string & parameters_varname,
      MultiphysicsSystem & system,
      CompositeQoI * qoi)
  {
    const unsigned int n_parameters =
      input.vector_variable_size(parameters_varname);
    libmesh_assert(n_parameters);

    this->parameter_name_list.resize(n_parameters);
    this->parameter_vector.clear();
    for (unsigned int i=0; i != n_parameters; ++i)
      {
        std::string param_name =
          input(parameters_varname, std::string(), i);

        this->parameter_name_list[i] = param_name;

        libMesh::ParameterMultiAccessor<libMesh::Number> *next_param =
          new libMesh::ParameterMultiAccessor<libMesh::Number>();

        // We always have Physics solving for u
        system.register_parameter(param_name, *next_param);

        // We don't always have QoIs when solving for du/dp
        if (qoi)
          qoi->register_parameter(param_name, *next_param);

        if (next_param->size() == 0)
          {
            std::cout << "No parameters named " << param_name <<
              " found in active Physics or QoIs" << std::endl;
            libmesh_error();
          }

        this->parameter_vector.push_back
          (libMesh::UniquePtr<libMesh::ParameterAccessor<libMesh::Number> >
           (next_param));
      }
  }
예제 #7
0
  void ConstantFunctionDirichletBCFactory::add_found_vars( const GetPot& input,
                                                           MultiphysicsSystem& system,
                                                           const std::string& section,
                                                           const std::set<std::string>& vars_found,
                                                           libMesh::CompositeFunction<libMesh::Number>& composite_func,
                                                           std::set<std::string>& vars_added ) const
  {
    libMesh::Number invalid_num = std::numeric_limits<libMesh::Number>::max();

    for( std::set<std::string>::const_iterator var = vars_found.begin();
         var != vars_found.end(); ++var )
      {
        std::vector<VariableIndex> var_idx(1,system.variable_number(*var));

        libMesh::Number value = input(section+"/"+(*var),invalid_num);

        libMesh::ConstFunction<libMesh::Number> const_func(value);
        composite_func.attach_subfunction(const_func,var_idx);
      }

    vars_added = vars_found;
  }
예제 #8
0
  libMesh::UniquePtr<FunctionType>
  ParsedFunctionDirichletOldStyleBCFactory<FunctionType>::build_func( const GetPot& input,
                                                                      MultiphysicsSystem& system,
                                                                      std::vector<std::string>& var_names,
                                                                      const std::string& section )
  {
    libmesh_assert_equal_to( var_names.size(), 1 );

    std::vector<VariableIndex> dbc_vars(1,system.variable_number(var_names[0]));

    std::string section_str = section+"/"+DirichletBCFactoryFunctionOldStyleBase<FunctionType>::_value_var_old_style;
    std::string expression = input(section_str,"DIE!",DirichletBCFactoryFunctionOldStyleBase<FunctionType>::_value_idx_old_style);

    libMesh::UniquePtr<FunctionType> all_funcs = this->build_composite_func();

    typedef typename TypeFrom<FunctionType>::to_composite composite_type;
    composite_type * composite_func =
      libMesh::cast_ptr<composite_type *>(all_funcs.get());

    composite_func->attach_subfunction
      (TypeFrom<FunctionType>::to_parsed(system, expression), dbc_vars);

    return all_funcs;
  }
  void PostProcessedQuantities<NumericType>::init_quantities( const MultiphysicsSystem& multiphysics_system,
							      libMesh::System& output_system,
							      const unsigned int component )
  {
    switch( component )
      {
      case(PERFECT_GAS_DENSITY):
	{
	  if( !multiphysics_system.has_physics(low_mach_navier_stokes) )
	    {
	      std::cerr << "Error: Must have "<< low_mach_navier_stokes 
			<< " enable for perfect gas density calculation."
			<< std::endl;
	      libmesh_error();
	    }
	  _quantity_var_map.insert
            ( std::make_pair(output_system.add_variable("rho", libMesh::FIRST),
                             PERFECT_GAS_DENSITY) );

	  _cache.add_quantity(Cache::PERFECT_GAS_DENSITY);
	}
	break;
	    
      case(MIXTURE_DENSITY):
	{
	  if( !multiphysics_system.has_physics(reacting_low_mach_navier_stokes) )
	    {
	      std::cerr << "Error: Must have "<< reacting_low_mach_navier_stokes 
			<< " enable for mixture gas density calculation."
			<< std::endl;
	      libmesh_error();
	    }
	  _quantity_var_map.insert
            ( std::make_pair(output_system.add_variable("rho", libMesh::FIRST),
                             MIXTURE_DENSITY) );

	  _cache.add_quantity(Cache::MIXTURE_DENSITY);
	}
	break;
	    
      case(PERFECT_GAS_VISCOSITY):
	{
	  libmesh_not_implemented();
	}
	break;
      case(SPECIES_VISCOSITY):
	{
	  if( !multiphysics_system.has_physics(reacting_low_mach_navier_stokes) )
	    {
	      std::cerr << "Error: Must have "<< reacting_low_mach_navier_stokes 
			<< " enable for species viscosity calculation."
			<< std::endl;
	      libmesh_error();
	    }

	  for( unsigned int s = 0; s < _species_names.size(); s++ )
	    {
	      VariableIndex var = output_system.add_variable
                ("mu_"+_species_names[s], libMesh::FIRST);
	      _species_var_map.insert( std::make_pair(var, s) );
	      _quantity_var_map.insert( std::make_pair(var, SPECIES_VISCOSITY) );
	    }
	  // We need T, p0, and mass fractions too
	  _cache.add_quantity(Cache::TEMPERATURE);
	  _cache.add_quantity(Cache::THERMO_PRESSURE);
	  _cache.add_quantity(Cache::MASS_FRACTIONS);
	  _cache.add_quantity(Cache::SPECIES_VISCOSITY);
	}
	break;

      case(MIXTURE_VISCOSITY):
	{
	  if( !multiphysics_system.has_physics(reacting_low_mach_navier_stokes) )
	    {
	      std::cerr << "Error: Must have "<< reacting_low_mach_navier_stokes 
			<< " enable for mixture viscosity calculation."
			<< std::endl;
	      libmesh_error();
	    }
	  _quantity_var_map.insert
            ( std::make_pair(output_system.add_variable("mu", libMesh::FIRST),
                             MIXTURE_VISCOSITY) );

	  _cache.add_quantity(Cache::MIXTURE_VISCOSITY);
	}
	break;

      case(PERFECT_GAS_THERMAL_CONDUCTIVITY):
	{
	  libmesh_not_implemented();
	}
	break;

      case(SPECIES_THERMAL_CONDUCTIVITY):
	{
	  if( !multiphysics_system.has_physics(reacting_low_mach_navier_stokes) )
	    {
	      std::cerr << "Error: Must have "<< reacting_low_mach_navier_stokes 
			<< " enable for species thermal conductivity calculation."
			<< std::endl;
	      libmesh_error();
	    }

	  for( unsigned int s = 0; s < _species_names.size(); s++ )
	    {
	      VariableIndex var = output_system.add_variable
                ("k_"+_species_names[s], libMesh::FIRST);
	      _species_var_map.insert( std::make_pair(var, s) );
	      _quantity_var_map.insert( std::make_pair(var, SPECIES_THERMAL_CONDUCTIVITY) );
	    }

	  _cache.add_quantity(Cache::SPECIES_THERMAL_CONDUCTIVITY);
	}
	break;

      case(MIXTURE_THERMAL_CONDUCTIVITY):
	{
	  if( !multiphysics_system.has_physics(reacting_low_mach_navier_stokes) )
	    {
	      std::cerr << "Error: Must have "<< reacting_low_mach_navier_stokes 
			<< " enable for mixture thermal conductivity calculation."
			<< std::endl;
	      libmesh_error();
	    }
	  _quantity_var_map.insert
            ( std::make_pair(output_system.add_variable("k", libMesh::FIRST),
                             MIXTURE_THERMAL_CONDUCTIVITY) );

	  _cache.add_quantity(Cache::MIXTURE_THERMAL_CONDUCTIVITY);
	}
	break;

      case(PERFECT_GAS_SPECIFIC_HEAT_P):
	{
	  libmesh_not_implemented();
	}
	break;

      case(SPECIES_SPECIFIC_HEAT_P):
	{
	  if( !multiphysics_system.has_physics(reacting_low_mach_navier_stokes) )
	    {
	      std::cerr << "Error: Must have "<< reacting_low_mach_navier_stokes 
			<< " enable for species cp calculation."
			<< std::endl;
	      libmesh_error();
	    }

	  for( unsigned int s = 0; s < _species_names.size(); s++ )
	    {
	      VariableIndex var = output_system.add_variable
                ("cp_"+_species_names[s], libMesh::FIRST);
	      _species_var_map.insert( std::make_pair(var, s) );
	      _quantity_var_map.insert( std::make_pair(var, SPECIES_SPECIFIC_HEAT_P) );
	    }

	  _cache.add_quantity(Cache::SPECIES_SPECIFIC_HEAT_P);
	}
	break;

      case(MIXTURE_SPECIFIC_HEAT_P):
	{
	  if( !multiphysics_system.has_physics(reacting_low_mach_navier_stokes) )
	    {
	      std::cerr << "Error: Must have "<< reacting_low_mach_navier_stokes 
			<< " enable for mixture cp calculation."
			<< std::endl;
	      libmesh_error();
	    }
	  _quantity_var_map.insert
            ( std::make_pair(output_system.add_variable("cp", libMesh::FIRST),
                             MIXTURE_SPECIFIC_HEAT_P) );

	  _cache.add_quantity(Cache::MIXTURE_SPECIFIC_HEAT_P);
	}
	break;

      case(PERFECT_GAS_SPECIFIC_HEAT_V):
	{
	  libmesh_not_implemented();
	}
	break;

      case(SPECIES_SPECIFIC_HEAT_V):
	{
	  if( !multiphysics_system.has_physics(reacting_low_mach_navier_stokes) )
	    {
	      std::cerr << "Error: Must have "<< reacting_low_mach_navier_stokes 
			<< " enable for species cv calculation."
			<< std::endl;
	      libmesh_error();
	    }

	  for( unsigned int s = 0; s < _species_names.size(); s++ )
	    {
	      VariableIndex var = output_system.add_variable
                ("cv_"+_species_names[s], libMesh::FIRST);
	      _species_var_map.insert( std::make_pair(var, s) );
	      _quantity_var_map.insert( std::make_pair(var, SPECIES_SPECIFIC_HEAT_V) );
	    }

	  _cache.add_quantity(Cache::SPECIES_SPECIFIC_HEAT_V);
	}
	break;

      case(MIXTURE_SPECIFIC_HEAT_V):
	{
	  if( !multiphysics_system.has_physics(reacting_low_mach_navier_stokes) )
	    {
	      std::cerr << "Error: Must have "<< reacting_low_mach_navier_stokes 
			<< " enable for mixture cv calculation."
			<< std::endl;
	      libmesh_error();
	    }
	  _quantity_var_map.insert
            ( std::make_pair(output_system.add_variable("cp", libMesh::FIRST),
                             MIXTURE_SPECIFIC_HEAT_V) );

	  _cache.add_quantity(Cache::MIXTURE_SPECIFIC_HEAT_V);
	}
	break;

      case(MOLE_FRACTIONS):
	{
	  if( !multiphysics_system.has_physics(reacting_low_mach_navier_stokes) )
	    {
	      std::cerr << "Error: Must have "<< reacting_low_mach_navier_stokes 
			<< " enable for mole fraction calculation."
			<< std::endl;
	      libmesh_error();
	    }

	  for( unsigned int s = 0; s < _species_names.size(); s++ )
	    {
	      VariableIndex var = output_system.add_variable
                ("X_"+_species_names[s], libMesh::FIRST);
	      _species_var_map.insert( std::make_pair(var, s) );
	      _quantity_var_map.insert( std::make_pair(var, MOLE_FRACTIONS) );
	    }

	  _cache.add_quantity(Cache::MOLE_FRACTIONS);
	}
	break;
		
      case(SPECIES_ENTHALPY):
	{
	  if( !multiphysics_system.has_physics(reacting_low_mach_navier_stokes) )
	    {
	      std::cerr << "Error: Must have "<< reacting_low_mach_navier_stokes 
			<< " enable for omega_dot calculation."
			<< std::endl;
	      libmesh_error();
	    }

	  for( unsigned int s = 0; s < _species_names.size(); s++ )
	    {
	      VariableIndex var = output_system.add_variable
                ("h_"+_species_names[s], libMesh::FIRST);
	      _species_var_map.insert( std::make_pair(var, s) );
	      _quantity_var_map.insert( std::make_pair(var, SPECIES_ENTHALPY) );
	    }

	  // We need T too
	  _cache.add_quantity(Cache::TEMPERATURE);
	  _cache.add_quantity(Cache::SPECIES_ENTHALPY);
	}
	break;

      case(OMEGA_DOT):
	{
	  if( !multiphysics_system.has_physics(reacting_low_mach_navier_stokes) )
	    {
	      std::cerr << "Error: Must have "<< reacting_low_mach_navier_stokes 
			<< " enable for omega_dot calculation."
			<< std::endl;
	      libmesh_error();
	    }

	  for( unsigned int s = 0; s < _species_names.size(); s++ )
	    {
	      VariableIndex var = output_system.add_variable
                ("omega_"+_species_names[s], libMesh::FIRST);
	      _species_var_map.insert( std::make_pair(var, s) );
	      _quantity_var_map.insert( std::make_pair(var, OMEGA_DOT) );
	    }

	  // We need T, p0, and mass fractions too
	  _cache.add_quantity(Cache::TEMPERATURE);
	  _cache.add_quantity(Cache::THERMO_PRESSURE);
	  _cache.add_quantity(Cache::MASS_FRACTIONS);
	  _cache.add_quantity(Cache::MIXTURE_DENSITY);
	  _cache.add_quantity(Cache::MIXTURE_GAS_CONSTANT);
	  _cache.add_quantity(Cache::MOLAR_DENSITIES);
	  _cache.add_quantity(Cache::SPECIES_NORMALIZED_ENTHALPY_MINUS_NORMALIZED_ENTROPY);
	  _cache.add_quantity(Cache::OMEGA_DOT);
	}
	break;

      default:
	{
	  std::cerr << "Error: Invalid quantity " << component << std::endl;
	  libmesh_error();
	}
      } // end switch

    return;
  }
예제 #10
0
  void OverlappingFluidSolidMap::build_maps( MultiphysicsSystem & system,
                                             const libMesh::PointLocatorBase & point_locator,
                                             const std::set<libMesh::subdomain_id_type> & solid_ids,
                                             const std::set<libMesh::subdomain_id_type> & fluid_ids,
                                             const DisplacementVariable & solid_disp_vars )
  {
    const libMesh::MeshBase & mesh = system.get_mesh();

    libMesh::UniquePtr<libMesh::DiffContext> raw_context = system.build_context();
    libMesh::UniquePtr<libMesh::FEMContext> fem_context( libMesh::cast_ptr<libMesh::FEMContext *>(raw_context.release()) );

    if( !mesh.is_serial() )
      libmesh_error_msg("ERROR: build_maps currently only implemented for ReplicatedMesh!");

    for( std::set<libMesh::subdomain_id_type>::const_iterator solid_id_it = solid_ids.begin();
         solid_id_it != solid_ids.end(); ++solid_id_it )
      for( libMesh::MeshBase::const_element_iterator e = mesh.active_subdomain_elements_begin(*solid_id_it);
           e != mesh.active_local_subdomain_elements_end(*solid_id_it);
           ++e )
        {
          // Convenience
          const libMesh::Elem * solid_elem = *e;

          // Setup FEMContext for computing solid displacements
          const std::vector<libMesh::Point>& qpoints =
            fem_context->get_element_fe(solid_disp_vars.u(),2)->get_xyz();

          fem_context->get_element_fe(solid_disp_vars.u(),2)->get_phi();

          fem_context->pre_fe_reinit(system,solid_elem);
          fem_context->elem_fe_reinit();

          // Find what fluid element contains each of the quadrature points and cache
          for( unsigned int qp = 0; qp < qpoints.size(); qp++ )
            {
              libMesh::Real u_disp = 0;
              libMesh::Real v_disp = 0;
              libMesh::Real w_disp = 0;

              fem_context->interior_value(solid_disp_vars.u(), qp, u_disp);
              if( solid_disp_vars.dim() >= 2 )
                fem_context->interior_value(solid_disp_vars.v(), qp, v_disp);
              if( solid_disp_vars.dim() == 3 )
                fem_context->interior_value(solid_disp_vars.w(), qp, w_disp);

              libMesh::Point U( u_disp, v_disp, w_disp );

              // We need to look for overlap with *displaced* solid point
              libMesh::Point x = qpoints[qp]+U;

              const libMesh::Elem * fluid_elem = point_locator( x, &fluid_ids );

              if( !fluid_elem )
                libmesh_error_msg("ERROR: Could not find fluid element for given displacement! Likely solid displaced off the fluid mesh!");

              // Now add to the solid elem->overlapping fluid elems map, but only if
              // the solid elem belongs to this processor
              {
                std::map<libMesh::dof_id_type,std::vector<unsigned int> > & fluid_elem_map =
                  _solid_to_fluid_map[solid_elem->id()];

                // The solid quadrature point that are in this overlapping fluid/solid element pair
                std::vector<unsigned int>& solid_qps = fluid_elem_map[fluid_elem->id()];
                solid_qps.push_back(qp);
              }

              // Now add to the fluid elem->overlapping solid elems map, but only if
              // the fluid elem belongs to this processor
              {
                std::map<libMesh::dof_id_type,std::vector<unsigned int> > & solid_elem_map =
                  _fluid_to_solid_map[fluid_elem->id()];

                // The solid quadrature point that are in this overlapping fluid/solid element pair
                std::vector<unsigned int>& solid_qps = solid_elem_map[solid_elem->id()];
                solid_qps.push_back(qp);
              }
            }
        }
  }
예제 #11
0
  void OldStyleBCBuilder::build_bcs( const GetPot& input, MultiphysicsSystem& system,
                                     std::vector<SharedPtr<NeumannBCContainer> >& neumann_bcs )
  {
    // Warn about deprecation of this horrid style
    {
      std::string warning = "WARNING: Specifying boundary conditions in the\n";
      warning += "         Physics sections is DEPRECATED! Please\n";
      warning += "         update your input file to new the newer\n";
      warning += "         style. See the examples for an illustration.\n";

      grins_warning(warning);
    }

    libMesh::DofMap& dof_map = system.get_dof_map();

    const PhysicsList& physics_list = system.get_physics_list();

    std::set<std::string> basic_physics;
    this->build_basic_physics(basic_physics);

    std::set<std::string> vel_and_temp_physics;
    this->build_vel_and_temp_physics(vel_and_temp_physics);

    std::set<std::string> reacting_physics;
    this->build_reacting_physics(reacting_physics);

    for( PhysicsListIter physics_iter = physics_list.begin();
         physics_iter != physics_list.end();
         physics_iter++ )
      {
        std::string physics_name = physics_iter->first;
        std::string raw_physics_name = PhysicsNaming::extract_physics(physics_name);

        std::string section_name = "Physics/"+physics_name;

        if( basic_physics.find( raw_physics_name ) != basic_physics.end() )
          {
            this->construct_bcs_old_style(input,
                                          system,
                                          raw_physics_name,
                                          section_name,
                                          "bc_ids",
                                          "bc_types",
                                          "bc_values",
                                          "bc_variables",
                                          dof_map,
                                          neumann_bcs);
          }

        if( (vel_and_temp_physics.find( raw_physics_name ) != vel_and_temp_physics.end()) ||
            (reacting_physics.find( raw_physics_name ) != reacting_physics.end()) )
          {
            this->construct_bcs_old_style(input,
                                          system,
                                          raw_physics_name,
                                          section_name,
                                          "vel_bc_ids",
                                          "vel_bc_types",
                                          "vel_bc_values",
                                          "vel_bc_variables",
                                          dof_map,
                                          neumann_bcs);

            this->construct_bcs_old_style(input,
                                          system,
                                          raw_physics_name,
                                          section_name,
                                          "temp_bc_ids",
                                          "temp_bc_types",
                                          "temp_bc_values",
                                          "temp_bc_variables",
                                          dof_map,
                                          neumann_bcs);
          }

        if( reacting_physics.find( raw_physics_name ) != reacting_physics.end() )
          {
            this->construct_bcs_old_style(input,
                                          system,
                                          raw_physics_name,
                                          section_name,
                                          "species_bc_ids",
                                          "species_bc_types",
                                          "species_bc_values",
                                          "species_bc_variables",
                                          dof_map,
                                          neumann_bcs);
          }
      }
  }