PSCF v1.3
|
Template class for Environments that mix and match field generators. More...
#include <MixAndMatchEnvTmpl.h>
Public Member Functions | |
MixAndMatchEnvTmpl () | |
Constructor. | |
~MixAndMatchEnvTmpl () | |
Destructor. | |
void | readParameters (std::istream &in) |
Read parameters from input stream. | |
void | generate () |
Checks if fields need to be (re)generated. | |
FG const & | fieldGenerator1 () const |
Get the first FieldGenerator by const reference. | |
FG const & | fieldGenerator2 () const |
Get the second FieldGenerator (if any) by const reference. | |
bool | hasFieldGenerator2 () const |
Does a second FieldGenerator exist? | |
GArray< ParameterType > | getParameterTypes () |
Get specialized sweep parameter types to add to a Sweep object. | |
void | setParameter (std::string name, DArray< int > ids, double value, bool &success) |
Set the value of a specialized sweep parameter. | |
double | getParameter (std::string name, DArray< int > ids, bool &success) const |
Get the value of a specialized sweep parameter. | |
void | setParameter (std::string name, DArray< int > ids, double value) |
Set the value of a specialized sweep parameter. | |
double | getParameter (std::string name, DArray< int > ids) const |
Get the value of a specialized sweep parameter. | |
void | setClassName (const char *className) |
Set class name string. | |
void | addParamComposite (ParamComposite &child, bool next=true) |
Add a child ParamComposite object to the format array. |
Protected Member Functions | |
virtual void | createGenerators ()=0 |
Create FieldGenerator objects for mask and/or external field. |
Protected Attributes | |
FG * | fieldGenPtr1_ |
Pointer to the first FieldGenerator object (required). | |
FG * | fieldGenPtr2_ |
Pointer to the second FieldGenerator object (optional). |
Template class for Environments that mix and match field generators.
An Environment in PSCF is an object that generates a mask and/or a set of external fields to impose upon the calculation. In some cases, one may wish to design multiple types of Environment subclasses that generate the same mask but different external fields, or vice versa. This class is designed to allow for such cases without the need for extensive duplicate code. In a MixAndMatchEnvTmpl object, the mask generation and external field generation are handled by separate FieldGenerator objects, which are owned by the MixAndMatchEnvTmpl. This way, multiple subclasses of MixAndMatchEnvTmpl can use the same FieldGenerator for their masks or external fields, a "mix-and-match" approach.
This class has two template parameters, Env and FG, both of which are class types. Env is the parent Environment class type, which may be EnvironmentBase or a subclass of EnvironmentBase. Similarly, FG is the class type for the FieldGenerator objects, which may be FieldGeneratorBase or a subclass of FieldGeneratorBase. This template structure allows for this class to be paired with a namespace-specific Environment base class, rather than the more generic EnvironmentBase, in cases where the Environment must assume namespace-specific functionality that is not defined in EnvironmentBase. In such cases, it may also be necessary to use a namespace-specific FieldGenerator base class that defines additional methods to accommodate the Environment class's namespace-specific functionality.
Fully defined subclasses of MixAndMatchEnvTmpl should have names that correspond to the type of Environment they generate (e.g., "FilmEnvironment" for thin-film systems). The only method that needs to be implemented by subclasses is createGenerators, which should dynamically allocate the types of FieldGenerator objects needed by that Environment and store pointers to them. Otherwise, all behavior is defined in this parent class.
Definition at line 59 of file MixAndMatchEnvTmpl.h.
Pscf::MixAndMatchEnvTmpl< Env, FG >::MixAndMatchEnvTmpl | ( | ) |
Constructor.
Definition at line 19 of file MixAndMatchEnvTmpl.tpp.
References fieldGenPtr1_, fieldGenPtr2_, and setClassName().
Pscf::MixAndMatchEnvTmpl< Env, FG >::~MixAndMatchEnvTmpl | ( | ) |
Destructor.
Definition at line 28 of file MixAndMatchEnvTmpl.tpp.
References fieldGenPtr1_, and fieldGenPtr2_.
void Pscf::MixAndMatchEnvTmpl< Env, FG >::readParameters | ( | std::istream & | in | ) |
Read parameters from input stream.
in | input stream |
Definition at line 49 of file MixAndMatchEnvTmpl.tpp.
References addParamComposite(), createGenerators(), fieldGenPtr1_, and UTIL_CHECK.
void Pscf::MixAndMatchEnvTmpl< Env, FG >::generate | ( | ) |
Checks if fields need to be (re)generated.
If so, generates them.
Definition at line 122 of file MixAndMatchEnvTmpl.tpp.
References fieldGenPtr1_, and fieldGenPtr2_.
FG const & Pscf::MixAndMatchEnvTmpl< Env, FG >::fieldGenerator1 | ( | ) | const |
Get the first FieldGenerator by const reference.
Definition at line 192 of file MixAndMatchEnvTmpl.tpp.
References fieldGenPtr1_, and UTIL_CHECK.
FG const & Pscf::MixAndMatchEnvTmpl< Env, FG >::fieldGenerator2 | ( | ) | const |
Get the second FieldGenerator (if any) by const reference.
Definition at line 203 of file MixAndMatchEnvTmpl.tpp.
References fieldGenPtr2_, and UTIL_CHECK.
bool Pscf::MixAndMatchEnvTmpl< Env, FG >::hasFieldGenerator2 | ( | ) | const |
Does a second FieldGenerator exist?
Definition at line 214 of file MixAndMatchEnvTmpl.tpp.
References fieldGenPtr2_.
GArray< ParameterType > Pscf::MixAndMatchEnvTmpl< Env, FG >::getParameterTypes | ( | ) |
Get specialized sweep parameter types to add to a Sweep object.
Definition at line 136 of file MixAndMatchEnvTmpl.tpp.
References Util::GArray< Data >::append(), fieldGenPtr1_, fieldGenPtr2_, and Util::GArray< Data >::size().
void Pscf::MixAndMatchEnvTmpl< Env, FG >::setParameter | ( | std::string | name, |
DArray< int > | ids, | ||
double | value, | ||
bool & | success ) |
Set the value of a specialized sweep parameter.
name | name of the specialized parameter |
ids | array of integer indices specifying value to set |
value | value to which the parameter is set |
success | boolean flag used to indicate if parameter was set |
Definition at line 154 of file MixAndMatchEnvTmpl.tpp.
References fieldGenPtr1_, and fieldGenPtr2_.
double Pscf::MixAndMatchEnvTmpl< Env, FG >::getParameter | ( | std::string | name, |
DArray< int > | ids, | ||
bool & | success ) const |
Get the value of a specialized sweep parameter.
name | name of the specialized parameter |
ids | array of integer indices specifying the value to get |
success | boolean Was the parameter found? |
Definition at line 173 of file MixAndMatchEnvTmpl.tpp.
References fieldGenPtr1_, and fieldGenPtr2_.
|
protectedpure virtual |
Create FieldGenerator objects for mask and/or external field.
This method must be defined by each subclass. In it, fieldGenPtr1_ and (optionally) fieldGenPtr2_ should be assigned to dynamically allocated FieldGenerator objects (created with "new" command). The actual class of each of these objects will be a subclass of FieldGenerator, the type of which will vary in each subclass of MixAndMatchEnvTmpl.
If only fieldGenPtr1_ is assigned, then it can be either type of FieldGenerator (Mask or External). If both fieldGenPtr1_ and fieldGenPtr2_ are assigned, then one of them must be of type Mask and the other must be of type External.
This is the only method that must be defined by subclasses of this class. All other methods are fully defined in this parent class.
Referenced by readParameters().
void Pscf::ParameterModifier::setParameter | ( | std::string | name, |
DArray< int > | ids, | ||
double | value ) |
Set the value of a specialized sweep parameter.
This is an overloaded version of the setParameter method above, which should be used only when the caller is certain that the specialized sweep parameter belongs to this ParameterModifier. An error will be thrown if the specialized parameter is not settable using this class.
name | name of the specialized parameter |
ids | array of integer indices specifying the value to set |
value | the value to which the parameter is set |
Definition at line 122 of file ParameterModifier.cpp.
double Pscf::ParameterModifier::getParameter | ( | std::string | name, |
DArray< int > | ids ) const |
Get the value of a specialized sweep parameter.
This is an overloaded version of the getParameter method above, which should be used only when the caller is certain that the specialized sweep parameter belongs to this ParameterModifier. An error will be thrown if the specialized parameter is not gettable using this class.
name | name of the specialized parameter |
ids | array of integer indices specifying the value to set |
Definition at line 136 of file ParameterModifier.cpp.
void Util::ParamComposite::setClassName | ( | const char * | className | ) |
Set class name string.
Should be set in subclass constructor.
Definition at line 900 of file ParamComposite.cpp.
Referenced by MixAndMatchEnvTmpl().
void Util::ParamComposite::addParamComposite | ( | ParamComposite & | child, |
bool | next = true ) |
Add a child ParamComposite object to the format array.
child | child ParamComposite object |
next | true if the indent level is one higher than parent. |
Definition at line 848 of file ParamComposite.cpp.
Referenced by readParameters().
|
protected |
Pointer to the first FieldGenerator object (required).
This FieldGenerator may generate a mask or a set of external fields.
Definition at line 164 of file MixAndMatchEnvTmpl.h.
Referenced by fieldGenerator1(), generate(), getParameter(), getParameterTypes(), MixAndMatchEnvTmpl(), readParameters(), setParameter(), and ~MixAndMatchEnvTmpl().
|
protected |
Pointer to the second FieldGenerator object (optional).
If fieldGenPtr1_ points to an object that generates a mask, then fieldGenPtr2_ points to an object that generates a set of external fields, and vice versa.
Definition at line 173 of file MixAndMatchEnvTmpl.h.
Referenced by fieldGenerator2(), generate(), getParameter(), getParameterTypes(), hasFieldGenerator2(), MixAndMatchEnvTmpl(), setParameter(), and ~MixAndMatchEnvTmpl().