Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 27 additions & 6 deletions include/aspect/particle/interpolator/interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <int dim>
std::string
interpolator_object_names ();
get_valid_interpolator_names_pattern ();


/**
Expand All @@ -113,10 +117,27 @@ namespace aspect
void (*declare_parameters_function) (ParameterHandler &),
std::unique_ptr<Interface<dim>> (*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 <int dim>
std::unique_ptr<Interface<dim>>
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.
Expand Down
42 changes: 33 additions & 9 deletions source/particle/interpolator/interface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,29 +58,45 @@ namespace aspect

template <int dim>
std::unique_ptr<Interface<dim>>
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<dim>(registered_plugins).create_plugin ("linear least squares",
"Particle::Interpolator name");
else
return std::get<dim>(registered_plugins).create_plugin (interpolator_name,
"Particle::Interpolator name");
}



template <int dim>
std::unique_ptr<Interface<dim>>
create_particle_interpolator (ParameterHandler &prm)
{
const std::string name = prm.get ("Interpolation scheme");

return std::get<dim>(registered_plugins).create_plugin (name,
"Particle::Interpolator name");
return create_particle_interpolator<dim> (name);
}


template <int dim>
std::string
get_valid_interpolator_names_pattern ()
{
return std::get<dim>(registered_plugins).get_pattern_of_names ();
}


template <int dim>
void
declare_parameters (ParameterHandler &prm)
{
// declare the entry in the parameter file
const std::string pattern_of_names
= std::get<dim>(registered_plugins).get_pattern_of_names ();
= get_valid_interpolator_names_pattern<dim>();

// 'bilinear least squares' is the deprecated old name of the 'linear least squares'
// interpolator. The old name will be removed in the future.
Expand Down Expand Up @@ -128,6 +144,10 @@ namespace aspect
void ( *) (ParameterHandler &), \
std::unique_ptr<Interface<dim>>( *) ()); \
\
template \
std::string \
get_valid_interpolator_names_pattern<dim> (); \
\
template \
void \
declare_parameters<dim> (ParameterHandler &); \
Expand All @@ -138,6 +158,10 @@ namespace aspect
\
template \
std::unique_ptr<Interface<dim>> \
create_particle_interpolator<dim> (const std::string &interpolator_name); \
\
template \
std::unique_ptr<Interface<dim>> \
create_particle_interpolator<dim> (ParameterHandler &prm);

ASPECT_INSTANTIATE(INSTANTIATE)
Expand Down
Loading