Skip to content

Commit

Permalink
Merge pull request #5950 from bangerth/manager-names
Browse files Browse the repository at this point in the history
Push the variable that stores the active plugin names down to the base class.
  • Loading branch information
gassmoeller authored Jun 28, 2024
2 parents 65adc5d + 4734558 commit 6da08a9
Show file tree
Hide file tree
Showing 15 changed files with 76 additions and 94 deletions.
6 changes: 0 additions & 6 deletions include/aspect/boundary_composition/interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,6 @@ namespace aspect
<< arg1
<< "> among the names of registered boundary composition objects.");
private:
/**
* A list of names of boundary composition objects that have been requested
* in the parameter file.
*/
std::vector<std::string> model_names;

/**
* A list of enums of boundary composition operators that have been
* requested in the parameter file. Each name is associated
Expand Down
6 changes: 0 additions & 6 deletions include/aspect/boundary_temperature/interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -263,12 +263,6 @@ namespace aspect
<< arg1
<< "> among the names of registered boundary temperature objects.");
private:
/**
* A list of names of boundary temperature objects that have been requested
* in the parameter file.
*/
std::vector<std::string> model_names;

/**
* A list of enums of boundary temperature operators that have been
* requested in the parameter file. Each name is associated
Expand Down
6 changes: 0 additions & 6 deletions include/aspect/heating_model/interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -329,12 +329,6 @@ namespace aspect
<< "Could not find entry <"
<< arg1
<< "> among the names of registered heating model objects.");
private:
/**
* A list of names of heating model objects that have been requested
* in the parameter file.
*/
std::vector<std::string> model_names;
};


Expand Down
6 changes: 0 additions & 6 deletions include/aspect/initial_composition/interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,6 @@ namespace aspect
<< arg1
<< "> among the names of registered initial composition objects.");
private:
/**
* A list of names of initial composition objects that have been requested
* in the parameter file.
*/
std::vector<std::string> model_names;

/**
* A list of enums of initial composition operators that have been
* requested in the parameter file. Each entry is used to modify the
Expand Down
6 changes: 0 additions & 6 deletions include/aspect/initial_temperature/interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,12 +201,6 @@ namespace aspect
<< arg1
<< "> among the names of registered initial temperature objects.");
private:
/**
* A list of names of initial temperature objects that have been requested
* in the parameter file.
*/
std::vector<std::string> model_names;

/**
* A list of enums of initial temperature operators that have been
* requested in the parameter file. Each entry is used to modify the
Expand Down
6 changes: 0 additions & 6 deletions include/aspect/particle/property/interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -754,12 +754,6 @@ namespace aspect
*/
unsigned int particle_world_index;

/**
* Stores the names of the plugins which are present
* in the order they are executed.
*/
std::vector<std::string> plugin_names;

/**
* A class that stores all information about the particle properties,
* their association with property plugins and their storage pattern.
Expand Down
23 changes: 23 additions & 0 deletions include/aspect/plugins.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,11 @@ namespace aspect
class ManagerBase : public InterfaceBase
{
public:
/**
* Destructor.
*/
~ManagerBase () override;

/**
* A function that is called at the beginning of each time step,
* calling the update function of the individual heating models.
Expand Down Expand Up @@ -256,9 +261,27 @@ namespace aspect
* parameter file.
*/
std::list<std::unique_ptr<InterfaceType>> plugin_objects;

/**
* A list of names used in the input file to identify plugins,
* corresponding to the plugin objects stored in the previous variable.
*/
std::vector<std::string> plugin_names;
};



template <typename InterfaceType>
ManagerBase<InterfaceType>::~ManagerBase()
{
// Not all derived manager classes currently set the 'plugin_names'
// variable, but for those that do, they better have as many names
// as there are plugins.
if (plugin_names.size() > 0)
Assert (plugin_names.size() == plugin_objects.size(), ExcInternalError());
}


template <typename InterfaceType>
void ManagerBase<InterfaceType>::update()
{
Expand Down
6 changes: 0 additions & 6 deletions include/aspect/termination_criteria/interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,12 +208,6 @@ namespace aspect
<< "Could not find entry <"
<< arg1
<< "> among the names of registered termination criteria objects.");
private:
/**
* A list of names corresponding to the termination criteria in the
* termination_objects.
*/
std::list<std::string> termination_obj_names;
};


Expand Down
16 changes: 8 additions & 8 deletions source/boundary_composition/interface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,29 +72,29 @@ namespace aspect
// parameters we declare here
prm.enter_subsection ("Boundary composition model");
{
model_names
this->plugin_names
= Utilities::split_string_list(prm.get("List of model names"));

AssertThrow(Utilities::has_unique_entries(model_names),
AssertThrow(Utilities::has_unique_entries(this->plugin_names),
ExcMessage("The list of strings for the parameter "
"'Boundary composition model/List of model names' contains entries more than once. "
"This is not allowed. Please check your parameter file."));

const std::string model_name = prm.get ("Model name");

AssertThrow (model_name == "unspecified" || model_names.size() == 0,
AssertThrow (model_name == "unspecified" || this->plugin_names.size() == 0,
ExcMessage ("The parameter 'Model name' is only used for reasons"
"of backwards compatibility and can not be used together with "
"the new functionality 'List of model names'. Please add your "
"boundary composition model to the list instead."));

if (!(model_name == "unspecified"))
model_names.push_back(model_name);
this->plugin_names.push_back(model_name);

// create operator list
std::vector<std::string> model_operator_names =
Utilities::possibly_extend_from_1_to_N (Utilities::split_string_list(prm.get("List of model operators")),
model_names.size(),
this->plugin_names.size(),
"List of model operators");
model_operators = Utilities::create_model_operator_list(model_operator_names);

Expand All @@ -111,7 +111,7 @@ namespace aspect
// ignore the set values, do not create objects that are never used.
if (fixed_composition_boundary_indicators.size() == 0)
{
model_names.clear();
this->plugin_names.clear();
model_operators.clear();
}
}
Expand All @@ -137,7 +137,7 @@ namespace aspect

// go through the list, create objects and let them parse
// their own parameters
for (auto &model_name : model_names)
for (auto &model_name : this->plugin_names)
{
// create boundary composition objects
this->plugin_objects.push_back (std::unique_ptr<Interface<dim>>
Expand Down Expand Up @@ -179,7 +179,7 @@ namespace aspect
const std::vector<std::string> &
Manager<dim>::get_active_boundary_composition_names () const
{
return model_names;
return this->plugin_names;
}


Expand Down
16 changes: 8 additions & 8 deletions source/boundary_temperature/interface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,29 +72,29 @@ namespace aspect
// parameters we declare here
prm.enter_subsection ("Boundary temperature model");
{
model_names
this->plugin_names
= Utilities::split_string_list(prm.get("List of model names"));

AssertThrow(Utilities::has_unique_entries(model_names),
AssertThrow(Utilities::has_unique_entries(this->plugin_names),
ExcMessage("The list of strings for the parameter "
"'Boundary temperature model/List of model names' contains entries more than once. "
"This is not allowed. Please check your parameter file."));

const std::string model_name = prm.get ("Model name");

AssertThrow (model_name == "unspecified" || model_names.size() == 0,
AssertThrow (model_name == "unspecified" || this->plugin_names.size() == 0,
ExcMessage ("The parameter 'Model name' is only used for reasons"
"of backwards compatibility and can not be used together with "
"the new functionality 'List of model names'. Please add your "
"boundary temperature model to the list instead."));

if (!(model_name == "unspecified"))
model_names.push_back(model_name);
this->plugin_names.push_back(model_name);

// create operator list
std::vector<std::string> model_operator_names =
Utilities::possibly_extend_from_1_to_N (Utilities::split_string_list(prm.get("List of model operators")),
model_names.size(),
this->plugin_names.size(),
"List of model operators");
model_operators = Utilities::create_model_operator_list(model_operator_names);

Expand All @@ -111,7 +111,7 @@ namespace aspect
// If that is indeed the case, clear the model_operators vector. Otherwise, raise an exception.
if (fixed_temperature_boundary_indicators.size() == 0)
{
AssertThrow(model_names.size() == 0,
AssertThrow(this->plugin_names.size() == 0,
ExcMessage ("You have indicated that you wish to apply a boundary temperature "
"model, but the <Fixed temperature boundary indicators> parameter "
"is empty. Please use this parameter to specify the boundaries "
Expand All @@ -134,7 +134,7 @@ namespace aspect

// go through the list, create objects and let them parse
// their own parameters
for (auto &model_name : model_names)
for (auto &model_name : this->plugin_names)
{
// create boundary temperature objects
this->plugin_objects.push_back (std::unique_ptr<Interface<dim>>
Expand Down Expand Up @@ -204,7 +204,7 @@ namespace aspect
const std::vector<std::string> &
Manager<dim>::get_active_boundary_temperature_names () const
{
return model_names;
return this->plugin_names;
}


Expand Down
8 changes: 4 additions & 4 deletions source/heating_model/interface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,10 @@ namespace aspect
// parameters we declare here
prm.enter_subsection ("Heating model");
{
model_names
this->plugin_names
= Utilities::split_string_list(prm.get("List of model names"));

AssertThrow(Utilities::has_unique_entries(model_names),
AssertThrow(Utilities::has_unique_entries(this->plugin_names),
ExcMessage("The list of strings for the parameter "
"'Heating model/List of model names' contains entries more than once. "
"This is not allowed. Please check your parameter file."));
Expand All @@ -117,7 +117,7 @@ namespace aspect

// go through the list, create objects and let them parse
// their own parameters
for (auto &model_name : model_names)
for (auto &model_name : this->plugin_names)
{
this->plugin_objects.push_back (std::unique_ptr<Interface<dim>>
(std::get<dim>(registered_plugins)
Expand Down Expand Up @@ -204,7 +204,7 @@ namespace aspect
const std::vector<std::string> &
Manager<dim>::get_active_heating_model_names () const
{
return model_names;
return this->plugin_names;
}


Expand Down
16 changes: 8 additions & 8 deletions source/initial_composition/interface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,36 +71,36 @@ namespace aspect
// parameters we declare here
prm.enter_subsection ("Initial composition model");
{
model_names
this->plugin_names
= Utilities::split_string_list(prm.get("List of model names"));

AssertThrow(Utilities::has_unique_entries(model_names),
AssertThrow(Utilities::has_unique_entries(this->plugin_names),
ExcMessage("The list of strings for the parameter "
"'Initial composition model/List of model names' contains entries more than once. "
"This is not allowed. Please check your parameter file."));

const std::string model_name = prm.get ("Model name");

AssertThrow (model_name == "unspecified" || model_names.size() == 0,
AssertThrow (model_name == "unspecified" || this->plugin_names.size() == 0,
ExcMessage ("The parameter 'Model name' is only used for reasons"
"of backwards compatibility and can not be used together with "
"the new functionality 'List of model names'. Please add your "
"initial composition model to the list instead."));

if (!(model_name == "unspecified"))
model_names.push_back(model_name);
this->plugin_names.push_back(model_name);

// create operator list
const std::vector<std::string> model_operator_names =
Utilities::possibly_extend_from_1_to_N (Utilities::split_string_list(prm.get("List of model operators")),
model_names.size(),
this->plugin_names.size(),
"List of model operators");
model_operators = Utilities::create_model_operator_list(model_operator_names);

}
prm.leave_subsection ();

if (model_names.size() > 0)
if (this->plugin_names.size() > 0)
AssertThrow(this->n_compositional_fields() > 0,
ExcMessage("A plugin for the initial composition condition was specified, but there "
"is no compositional field. This can lead to errors within the initialization of "
Expand All @@ -109,7 +109,7 @@ namespace aspect

// go through the list, create objects and let them parse
// their own parameters
for (const auto &model_name : model_names)
for (const auto &model_name : this->plugin_names)
{
this->plugin_objects.push_back (std::unique_ptr<Interface<dim>>
(std::get<dim>(registered_plugins)
Expand Down Expand Up @@ -149,7 +149,7 @@ namespace aspect
const std::vector<std::string> &
Manager<dim>::get_active_initial_composition_names () const
{
return model_names;
return this->plugin_names;
}


Expand Down
14 changes: 7 additions & 7 deletions source/initial_temperature/interface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,37 +68,37 @@ namespace aspect
// parameters we declare here
prm.enter_subsection ("Initial temperature model");
{
model_names
this->plugin_names
= Utilities::split_string_list(prm.get("List of model names"));

AssertThrow(Utilities::has_unique_entries(model_names),
AssertThrow(Utilities::has_unique_entries(this->plugin_names),
ExcMessage("The list of strings for the parameter "
"'Initial temperature model/List of model names' contains entries more than once. "
"This is not allowed. Please check your parameter file."));

const std::string model_name = prm.get ("Model name");

AssertThrow (model_name == "unspecified" || model_names.size() == 0,
AssertThrow (model_name == "unspecified" || this->plugin_names.size() == 0,
ExcMessage ("The parameter 'Model name' is only used for reasons"
"of backwards compatibility and can not be used together with "
"the new functionality 'List of model names'. Please add your "
"initial temperature model to the list instead."));

if (!(model_name == "unspecified"))
model_names.push_back(model_name);
this->plugin_names.push_back(model_name);

// create operator list
const std::vector<std::string> model_operator_names =
Utilities::possibly_extend_from_1_to_N (Utilities::split_string_list(prm.get("List of model operators")),
model_names.size(),
this->plugin_names.size(),
"List of model operators");
model_operators = Utilities::create_model_operator_list(model_operator_names);
}
prm.leave_subsection ();

// go through the list, create objects and let them parse
// their own parameters
for (auto &model_name : model_names)
for (auto &model_name : this->plugin_names)
{
// create initial temperature objects
this->plugin_objects.push_back (std::unique_ptr<Interface<dim>>
Expand Down Expand Up @@ -137,7 +137,7 @@ namespace aspect
const std::vector<std::string> &
Manager<dim>::get_active_initial_temperature_names () const
{
return model_names;
return this->plugin_names;
}


Expand Down
Loading

0 comments on commit 6da08a9

Please sign in to comment.