<commit_before>#include "InitialCondition.h"
#include "InitialConditionFactory.h"

// libMesh includes
#include "libmesh.h"
#include "point.h"
#include "InputParameters.h"
#include "vector_value.h"
#include "equation_systems.h"
#include "explicit_system.h"

namespace Moose
{
  Number initial_value (const Point& p,
                        const Parameters& parameters,
                        const std::string& sys_name,
                        const std::string& var_name)
  {
    // Try to grab an InitialCondition object for this variable.
    InitialCondition * ic = InitialConditionFactory::instance()->getInitialCondition(0, var_name);
    
    if(ic)
      return ic->value(p);
   
    if(parameters.have_parameter<Real>("initial_"+var_name))
      return parameters.get<Real>("initial_"+var_name);
    
    return 0;
  }

  Gradient initial_gradient (const Point& p,
                             const Parameters& parameters,
                             const std::string& sys_name,
                             const std::string& var_name)
  {
    return RealGradient();
  }

  void initial_condition(EquationSystems& es, const std::string& system_name)
  {
    ExplicitSystem & system = es.get_system<ExplicitSystem>(system_name);
    
    system.project_solution(initial_value, initial_gradient, es.parameters);
  }
}<commit_msg>allow setting initial gradient with new initial condition system<commit_after>#include "InitialCondition.h"
#include "InitialConditionFactory.h"

// libMesh includes
#include "libmesh.h"
#include "point.h"
#include "InputParameters.h"
#include "vector_value.h"
#include "equation_systems.h"
#include "explicit_system.h"

namespace Moose
{
  Number initial_value (const Point& p,
                        const Parameters& parameters,
                        const std::string& sys_name,
                        const std::string& var_name)
  {
    // Try to grab an InitialCondition object for this variable.
    InitialCondition * ic = InitialConditionFactory::instance()->getInitialCondition(0, var_name);
    
    if(ic)
      return ic->value(p);
   
    if(parameters.have_parameter<Real>("initial_"+var_name))
      return parameters.get<Real>("initial_"+var_name);
    
    return 0;
  }

  Gradient initial_gradient (const Point& p,
                             const Parameters& parameters,
                             const std::string& sys_name,
                             const std::string& var_name)
  {
    // Try to grab an InitialCondition object for this variable.
    InitialCondition * ic = InitialConditionFactory::instance()->getInitialCondition(0, var_name);
    
    if(ic)
      return ic->gradient(p);

    return RealGradient();
  }

  void initial_condition(EquationSystems& es, const std::string& system_name)
  {
    ExplicitSystem & system = es.get_system<ExplicitSystem>(system_name);
    
    system.project_solution(initial_value, initial_gradient, es.parameters);
  }
}
{'fraction_non_alphanumeric': 0.1010854816824966, 'fraction_numerical': 0.0016960651289009499, 'mean_word_length': 2.7953667953667956, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3424850', 'n_tokens_mistral': 833, 'n_tokens_neox': 807, 'n_words': 190}