OpenMPCD
BoundaryCondition/Factory.cpp
2 
4 
5 #include <iostream>
6 
7 namespace OpenMPCD
8 {
9 namespace CUDA
10 {
11 namespace BoundaryCondition
12 {
13 
15  const Configuration::Setting& config,
16  const unsigned int simulationBoxSizeX,
17  const unsigned int simulationBoxSizeY,
18  const unsigned int simulationBoxSizeZ)
19 {
20  if(config.getChildCount() == 0)
21  {
24  "No boundary condition configured.");
25  }
26 
27  if(config.getChildCount() == 2)
28  {
29  if( config.read<std::string>("type") != "Lees-Edwards"
30  ||
31  !config.has("shearRate"))
32  {
35  "Boundary condition configuration malformed.");
36  }
37 
38  std::cout << "Warning: This style of boundary condition configuration ";
39  std::cout << "is deprecated.\n";
40 
41  Configuration newConfig;
42  newConfig.set("LeesEdwards.shearRate", config.read<FP>("shearRate"));
43  return new LeesEdwards(
44  newConfig.getSetting("LeesEdwards"),
45  simulationBoxSizeX, simulationBoxSizeY, simulationBoxSizeZ);
46  }
47 
48  if(config.getChildCount() != 1)
49  {
52  "Boundary condition configuration malformed.");
53  }
54 
55 
56  if(config.has("LeesEdwards"))
57  {
58  return new LeesEdwards(
59  config.getSetting("LeesEdwards"),
60  simulationBoxSizeX, simulationBoxSizeY, simulationBoxSizeZ);
61  }
62 
65  "Unknown boundary condition configured.");
66 }
67 } //namespace BoundaryCondition
68 } //namespace CUDA
69 } //namespace OpenMPCD
OpenMPCD::Configuration::getSetting
const Setting getSetting(const std::string &name) const
Returns the setting object with the given name.
Definition: Configuration.hpp:579
OpenMPCD::CUDA::BoundaryCondition::Factory::getInstance
static BoundaryCondition::Base * getInstance(const Configuration::Setting &config, const unsigned int simulationBoxSizeX, const unsigned int simulationBoxSizeY, const unsigned int simulationBoxSizeZ)
Returns a newly constructed boundary condition instance.
Definition: BoundaryCondition/Factory.cpp:14
OpenMPCD::Configuration::Setting::getChildCount
std::size_t getChildCount() const
Returns the number of direct child settings in this setting.
Definition: Configuration.hpp:235
OpenMPCD::Configuration
Represents the configuration of the simulation.
Definition: Configuration.hpp:28
OPENMPCD_THROW
#define OPENMPCD_THROW(ExceptionType, message)
Throws the given ExceptionType, passing the given message along with file and line number information...
Definition: Exceptions.hpp:22
OpenMPCD::CUDA::BoundaryCondition::LeesEdwards
Lees-Edwards boundary conditions.
Definition: LeesEdwards.hpp:31
OpenMPCD::Configuration::Setting::has
bool has(const std::string &settingName) const
Returns whether a setting with the given name exists.
Definition: Configuration.hpp:82
Factory.hpp
OpenMPCD::Configuration::Setting::getSetting
const Setting getSetting(const std::string &name) const
Returns the setting object with the given name.
Definition: Configuration.hpp:275
LeesEdwards.hpp
OpenMPCD::Configuration::set
void set(const std::string &setting, const ValueType value)
Sets a setting's value.
Definition: Configuration.hpp:661
OpenMPCD::FP
double FP
Default floating point type.
Definition: Types.hpp:13
OpenMPCD::Configuration::Setting
Represents a setting in the configuration.
Definition: Configuration.hpp:36
OpenMPCD::InvalidConfigurationException
Represents an invalid configuration.
Definition: Exceptions.hpp:80
OpenMPCD::CUDA::BoundaryCondition::Base
Base class for boundary condition.
Definition: CUDA/BoundaryCondition/Base.hpp:26
OpenMPCD::Configuration::Setting::read
void read(const std::string &name, ValueType *const value) const
Reads the specified setting and stores it at the given location.
Definition: Configuration.hpp:131