Skip to content

Commit

Permalink
Plugins: SiteWiseForces step
Browse files Browse the repository at this point in the history
git-svn-id: https://scm.projects.hlrs.de/svn/ls1/MarDyn/trunk@6363 a63bd714-7e14-4b5e-94e7-302c8c8ff188
  • Loading branch information
kruegener committed Jul 4, 2018
1 parent cb63f78 commit a481a6a
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 62 deletions.
27 changes: 10 additions & 17 deletions src/Simulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ void Simulation::readXML(XMLfileUnits& xmlconfig) {
Simulation::exit(1);
}

// TODO: move parts to readXML in TemperatureControl?
/* thermostats */
if(xmlconfig.changecurrentnode("thermostats")) {
long numThermostats = 0;
Expand Down Expand Up @@ -413,6 +414,9 @@ void Simulation::readXML(XMLfileUnits& xmlconfig) {
global_log->error() << "Instance of TemperatureControl allready exist! Programm exit ..." << endl;
Simulation::exit(-1);
}
}
else if(thermostattype == "Andersen"){

}
else
{
Expand Down Expand Up @@ -971,11 +975,12 @@ void Simulation::simulate() {

_moleculeContainer->traverseCells(*_cellProcessor);

// TODO: REMOVE HACK AND INTRODUCE PLUGIN STEP
WallPotential* wp = dynamic_cast<WallPotential*>(getPlugin("WallPotential"));
if(wp != NULL){
wp -> forceStep(_moleculeContainer, _domainDecomposition, _simstep);
}
// siteWiseForces Plugin Call
global_log -> debug() << "[SITEWISE FORCES] Performing siteWiseForces plugin call" << endl;
for (auto plugin : _plugins) {
global_log -> debug() << "[SITEWISE FORCES] Plugin: " << plugin->getPluginName() << endl;
plugin->siteWiseForces(_moleculeContainer, _domainDecomposition, _simstep);
}

// Update forces in molecules so they can be exchanged
updateForces();
Expand Down Expand Up @@ -1402,18 +1407,6 @@ PluginBase* Simulation::getPlugin(const std::string& name) {
return nullptr;
}

/*void Simulation::measureFLOPRate(ParticleContainer* cont, unsigned long simstep) {
PluginBase * flopRateBase = getOutputPlugin("FlopRateWriter");
if (flopRateBase == nullptr) {
return;
}
FlopRateWriter * flopRateWriter = dynamic_cast<FlopRateWriter * >(flopRateBase);
mardyn_assert(flopRateWriter != nullptr);
flopRateWriter->measureFLOPS(cont, simstep);
}*/

unsigned long Simulation::getNumberOfTimesteps() const {
return _numberOfTimesteps;
}
Expand Down
4 changes: 3 additions & 1 deletion src/Simulation.h
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,9 @@ class Simulation {
*/
PluginBase* getPlugin(const std::string& name);

//void measureFLOPRate(ParticleContainer * cont, unsigned long simstep);
std::list<PluginBase*>* getPluginList(){
return &_plugins;
}

/** Global energy log */
void initGlobalEnergyLog();
Expand Down
7 changes: 7 additions & 0 deletions src/parallel/NonBlockingMPIHandlerBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "particleContainer/ParticleContainer.h"
#include "Domain.h"
#include "particleContainer/adapter/CellProcessor.h"
#include "plugins/PluginBase.h"

using Log::global_log;

Expand Down Expand Up @@ -56,6 +57,12 @@ void NonBlockingMPIHandlerBase::performComputation() {
global_simulation->timers()->start("SIMULATION_FORCE_CALCULATION");
_moleculeContainer->traverseCells(*_cellProcessor);

// siteWiseForces Plugin Call
global_log -> debug() << "[SITEWISE FORCES] Performing siteWiseForces plugin (nonBlocking) call" << endl;
for (PluginBase* plugin : *global_simulation->getPluginList()) {
global_log -> debug() << "[SITEWISE FORCES] Plugin: " << plugin->getPluginName() << endl;
plugin->siteWiseForces(_moleculeContainer, _domainDecomposition, global_simulation->getSimulationStep());
}

// Update forces in molecules so they can be exchanged
const ParticleIterator begin = _moleculeContainer->iterator();
Expand Down
7 changes: 7 additions & 0 deletions src/parallel/NonBlockingMPIMultiStepHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,13 @@ void NonBlockingMPIMultiStepHandler::performComputation() {
_moleculeContainer->traverseNonInnermostCells(*_cellProcessor);
_cellProcessor->endTraversal();

// siteWiseForces Plugin Call
global_log -> debug() << "[SITEWISE FORCES] Performing siteWiseForces plugin (nonBlocking) call" << endl;
for (PluginBase* plugin : *global_simulation->getPluginList()) {
global_log -> debug() << "[SITEWISE FORCES] Plugin: " << plugin->getPluginName() << endl;
plugin->siteWiseForces(_moleculeContainer, _domainDecomposition, global_simulation->getSimulationStep());
}

// Update forces in molecules so they can be exchanged - new - begin
const ParticleIterator begin = _moleculeContainer->iterator();
for (ParticleIterator i = begin; i.hasNext(); i.next()){
Expand Down
14 changes: 11 additions & 3 deletions src/plugins/PluginBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,26 @@ class PluginBase {
) {};

/** @brief Method beforeForces will be called before forcefields have been applied
* no alterations w.r.t. Forces shall be made here
*
* make pure Virtual ?
*/

virtual void beforeForces(
ParticleContainer* particleContainer, DomainDecompBase* domainDecomp,
unsigned long simstep
) {};

/** @brief Method siteWiseForces will be called before forcefields have been applied
* alterations to sitewise forces and fullMolecule forces can be made here
*/

virtual void siteWiseForces(
ParticleContainer* particleContainer, DomainDecompBase* domainDecomp,
unsigned long simstep
) {};

/** @brief Method afterForces will be called after forcefields have been applied
*
* make pure Virtual ?
* no sitewise Forces can be applied here
*/
virtual void afterForces(
ParticleContainer* particleContainer, DomainDecompBase* domainDecomp,
Expand Down
28 changes: 2 additions & 26 deletions src/plugins/WallPotential.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,32 +315,8 @@ void WallPotential::calcTSLJ_10_4(ParticleContainer *partContainer) {
}
// end method calcTSLJ_10_4(...)

void WallPotential::beforeForces(ParticleContainer *particleContainer, DomainDecompBase *domainDecomp,
unsigned long simstep) {

}

void WallPotential::afterForces(ParticleContainer *particleContainer, DomainDecompBase *domainDecomp,
unsigned long simstep) {
/*
if(simstep == 0){
return;
}
if(_potential == LJ9_3){
//global_log->debug() << "[WallPotential] LJ9_3 afterForces." << endl;
this->calcTSLJ_9_3(particleContainer);
//global_log->debug() << "[WallPotential] LJ9_3 applied." << endl;
}
else if(_potential == LJ10_4){
//global_log->debug() << "[WallPotential] LJ10_4 afterForces. " << endl;
this->calcTSLJ_10_4(particleContainer);
//global_log->debug() << "[WallPotential] LJ10_4 applied." << endl;
}
*/
}

void WallPotential::forceStep(ParticleContainer *particleContainer, DomainDecompBase *domainDecomp,
unsigned long simstep) {
void WallPotential::siteWiseForces(ParticleContainer *particleContainer, DomainDecompBase *domainDecomp,
unsigned long simstep) {

if(simstep == 0){
return;
Expand Down
18 changes: 3 additions & 15 deletions src/plugins/WallPotential.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,24 +91,12 @@ class WallPotential : public PluginBase{
delete [] _uPot_10_4_3;
};

void init(ParticleContainer* particleContainer, DomainDecompBase* domainDecomp, Domain* domain) {
void init(ParticleContainer* particleContainer, DomainDecompBase* domainDecomp, Domain* domain) override {
global_log -> debug() << "[WallPotential] Wall enabled" << std::endl;
_domain = domain;
}

void readXML (XMLfileUnits& xmlconfig);

void beforeEventNewTimestep(
ParticleContainer* particleContainer, DomainDecompBase* domainDecomp,
unsigned long simstep
){}

void beforeForces(ParticleContainer* particleContainer, DomainDecompBase* domainDecomp, unsigned long simstep);

void afterForces(
ParticleContainer* particleContainer, DomainDecompBase* domainDecomp,
unsigned long simstep
);
void readXML (XMLfileUnits& xmlconfig) override;

void endStep(
ParticleContainer *particleContainer, DomainDecompBase *domainDecomp,
Expand All @@ -131,7 +119,7 @@ class WallPotential : public PluginBase{

void calcTSLJ_10_4(ParticleContainer *partContainer);

void forceStep(ParticleContainer* particleContainer, DomainDecompBase* domainDecomp,
void siteWiseForces(ParticleContainer* particleContainer, DomainDecompBase* domainDecomp,
unsigned long simstep);
};

Expand Down

0 comments on commit a481a6a

Please sign in to comment.