diff --git a/include/aspect/particle/interpolator/interface.h b/include/aspect/particle/interpolator/interface.h index 97fc2198418..446fc8c8f90 100644 --- a/include/aspect/particle/interpolator/interface.h +++ b/include/aspect/particle/interpolator/interface.h @@ -84,11 +84,15 @@ namespace aspect /** - * Return a list of names (separated by '|') of possible interpolator - * classes for particles. + * Return a string that consists of the names of interpolator classes + * for particles that can be selected. + * These names are separated by a vertical line '|' so + * that the string can be an input to the deal.II classes + * Patterns::Selection or Patterns::MultipleSelection. */ + template std::string - interpolator_object_names (); + get_valid_interpolator_names_pattern (); /** @@ -113,10 +117,27 @@ namespace aspect void (*declare_parameters_function) (ParameterHandler &), std::unique_ptr> (*factory_function) ()); + + /** + * A function that given the name of an interpolation scheme + * returns a pointer to an object that describes it. + * Ownership of the pointer is transferred to the caller. + * + * The model object returned is not yet initialized and has not + * read its runtime parameters yet. + * + * @ingroup ParticleInterpolators + */ + template + std::unique_ptr> + create_particle_interpolator (const std::string &interpolator_name); + + /** - * A function that given the name of a model returns a pointer to an - * object that describes it. Ownership of the pointer is transferred to - * the caller. + * A function that reads the name of an interpolation scheme + * from the parameter object and then returns a pointer + * to an object that describes it. + * Ownership of the pointer is transferred to the caller. * * The model object returned is not yet initialized and has not * read its runtime parameters yet. diff --git a/source/particle/interpolator/interface.cc b/source/particle/interpolator/interface.cc index c5431373bdb..34b04e242ca 100644 --- a/source/particle/interpolator/interface.cc +++ b/source/particle/interpolator/interface.cc @@ -58,21 +58,37 @@ namespace aspect template std::unique_ptr> - create_particle_interpolator (ParameterHandler &prm) + create_particle_interpolator (const std::string &interpolator_name) { - std::string name; - name = prm.get ("Interpolation scheme"); - // 'bilinear least squares' is the deprecated old name of the 'linear least squares' // interpolator. The old name will be removed in the future. - if (name == "bilinear least squares") - name = "linear least squares"; + if (interpolator_name == "bilinear least squares") + return std::get(registered_plugins).create_plugin ("linear least squares", + "Particle::Interpolator name"); + else + return std::get(registered_plugins).create_plugin (interpolator_name, + "Particle::Interpolator name"); + } + + + + template + std::unique_ptr> + create_particle_interpolator (ParameterHandler &prm) + { + const std::string name = prm.get ("Interpolation scheme"); - return std::get(registered_plugins).create_plugin (name, - "Particle::Interpolator name"); + return create_particle_interpolator (name); } + template + std::string + get_valid_interpolator_names_pattern () + { + return std::get(registered_plugins).get_pattern_of_names (); + } + template void @@ -80,7 +96,7 @@ namespace aspect { // declare the entry in the parameter file const std::string pattern_of_names - = std::get(registered_plugins).get_pattern_of_names (); + = get_valid_interpolator_names_pattern(); // 'bilinear least squares' is the deprecated old name of the 'linear least squares' // interpolator. The old name will be removed in the future. @@ -128,6 +144,10 @@ namespace aspect void ( *) (ParameterHandler &), \ std::unique_ptr>( *) ()); \ \ + template \ + std::string \ + get_valid_interpolator_names_pattern (); \ + \ template \ void \ declare_parameters (ParameterHandler &); \ @@ -138,6 +158,10 @@ namespace aspect \ template \ std::unique_ptr> \ + create_particle_interpolator (const std::string &interpolator_name); \ + \ + template \ + std::unique_ptr> \ create_particle_interpolator (ParameterHandler &prm); ASPECT_INSTANTIATE(INSTANTIATE)