Skip to content
Snippets Groups Projects
Commit e43865d7 authored by Gareth Tribello's avatar Gareth Tribello
Browse files

Some small tidy ups in ActionWithDistribution class.

parent d312719b
No related branches found
No related tags found
No related merge requests found
...@@ -38,7 +38,6 @@ void ActionWithDistribution::autoParallelize(Keywords& keys){ ...@@ -38,7 +38,6 @@ void ActionWithDistribution::autoParallelize(Keywords& keys){
ActionWithDistribution::ActionWithDistribution(const ActionOptions&ao): ActionWithDistribution::ActionWithDistribution(const ActionOptions&ao):
Action(ao), Action(ao),
read(false), read(false),
all_values(true),
serial(false), serial(false),
updateFreq(0), updateFreq(0),
lastUpdate(0), lastUpdate(0),
...@@ -64,9 +63,12 @@ ActionWithDistribution::~ActionWithDistribution(){ ...@@ -64,9 +63,12 @@ ActionWithDistribution::~ActionWithDistribution(){
for(unsigned i=0;i<functions.size();++i) delete functions[i]; for(unsigned i=0;i<functions.size();++i) delete functions[i];
} }
void ActionWithDistribution::requestDistribution(){ void ActionWithDistribution::addVessel( const std::string& name, const std::string& input ){
read=true; read=true; VesselOptions da(name,input,this);
functions.push_back( vesselRegister().create(name,da) );
}
void ActionWithDistribution::requestDistribution(){
// Loop over all keywords find the vessels and create appropriate functions // Loop over all keywords find the vessels and create appropriate functions
for(unsigned i=0;i<keywords.size();++i){ for(unsigned i=0;i<keywords.size();++i){
std::string thiskey,input; thiskey=keywords.getKeyword(i); std::string thiskey,input; thiskey=keywords.getKeyword(i);
...@@ -75,35 +77,29 @@ void ActionWithDistribution::requestDistribution(){ ...@@ -75,35 +77,29 @@ void ActionWithDistribution::requestDistribution(){
// If the keyword is a flag read it in as a flag // If the keyword is a flag read it in as a flag
if( keywords.style(thiskey,"flag") ){ if( keywords.style(thiskey,"flag") ){
bool dothis; parseFlag(thiskey,dothis); bool dothis; parseFlag(thiskey,dothis);
VesselOptions da(thiskey,input,this); if(dothis) addVessel( thiskey, input );
if(dothis) functions.push_back( vesselRegister().create(thiskey,da) );
// If it is numbered read it in as a numbered thing // If it is numbered read it in as a numbered thing
} else if( keywords.numbered(thiskey) ) { } else if( keywords.numbered(thiskey) ) {
parse(thiskey,input); parse(thiskey,input);
if(input.size()!=0){ if(input.size()!=0){
VesselOptions da(thiskey,input,this); addVessel( thiskey, input );
functions.push_back(vesselRegister().create(thiskey,da) );
} else { } else {
for(unsigned i=1;;++i){ for(unsigned i=1;;++i){
if( !parseNumbered(thiskey,i,input) ) break; if( !parseNumbered(thiskey,i,input) ) break;
std::string ss; Tools::convert(i,ss); std::string ss; Tools::convert(i,ss);
VesselOptions da(thiskey,input,this); addVessel( thiskey, input );
functions.push_back(vesselRegister().create(thiskey,da) );
input.clear(); input.clear();
} }
} }
// Otherwise read in the keyword the normal way // Otherwise read in the keyword the normal way
} else { } else {
parse(thiskey, input); parse(thiskey, input);
VesselOptions da(thiskey,input,this); if(input.size()!=0) addVessel(thiskey,input);
if(input.size()!=0) functions.push_back( vesselRegister().create(thiskey,da) );
} }
input.clear(); input.clear();
} }
} }
if( functions.size()>0 ) all_values=false;
if(all_values) error("No function has been specified");
// This sets up the dynamic list that holds what we are calculating // This sets up the dynamic list that holds what we are calculating
for(unsigned i=0;i<getNumberOfFunctionsInAction();++i){ members.addIndexToList(i); } for(unsigned i=0;i<getNumberOfFunctionsInAction();++i){ members.addIndexToList(i); }
activateAll(); resizeFunctions(); activateAll(); resizeFunctions();
......
...@@ -45,8 +45,6 @@ friend class FieldVessel; ...@@ -45,8 +45,6 @@ friend class FieldVessel;
private: private:
/// This is used to ensure that we have properly read the action /// This is used to ensure that we have properly read the action
bool read; bool read;
/// This tells us we are calculating all values (not doing anything to the distribution)
bool all_values;
/// Do all calculations in serial /// Do all calculations in serial
bool serial; bool serial;
/// Everything for controlling the updating of neighbor lists /// Everything for controlling the updating of neighbor lists
...@@ -66,6 +64,8 @@ private: ...@@ -66,6 +64,8 @@ private:
/// Activate all the values in the list /// Activate all the values in the list
void activateAll(); void activateAll();
protected: protected:
/// Add a vessel to the list of vessels
void addVessel( const std::string& name, const std::string& input );
/// Complete the setup of this object (this routine must be called after construction of ActionWithValue) /// Complete the setup of this object (this routine must be called after construction of ActionWithValue)
void requestDistribution(); void requestDistribution();
/// Return the value of the tolerance /// Return the value of the tolerance
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment