Skip to content

Commit

Permalink
doc + move + sanity check COMaligner
Browse files Browse the repository at this point in the history
git-svn-id: https://scm.projects.hlrs.de/svn/ls1/MarDyn/trunk@6262 a63bd714-7e14-4b5e-94e7-302c8c8ff188
  • Loading branch information
kruegener committed May 28, 2018
1 parent 497c9db commit 39d13dc
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 4 deletions.
17 changes: 14 additions & 3 deletions src/utils/COMaligner.cpp → src/plugins/COMaligner.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ void COMaligner::readXML(XMLfileUnits& xmlconfig){
xmlconfig.getNodeValue("interval", _interval);
xmlconfig.getNodeValue("correctionFactor", _alignmentCorrection);

// SANITY CHECK
if(_interval < 1 || _alignmentCorrection < 0 || _alignmentCorrection > 1){
global_log -> error() << "[COMaligner] INVALID CONFIGURATION!!! DISABLED!" << std::endl;
_enabled = false;
// TODO: THROW REAL ERROR AND HALT SIMULATION?
return;
}

global_log -> info() << "[COMaligner] settings:" << std::endl;
global_log -> info() << " x: " << _alignX << std::endl;
global_log -> info() << " y: " << _alignY << std::endl;
Expand Down Expand Up @@ -151,6 +159,7 @@ void COMaligner::beforeForces(ParticleContainer* particleContainer,
// TODO: Check if ComponentID check is important
// TODO: CHECK IF MPI IMPLEMENTATION NECESSARY
// TODO: WRITE UNIT TEST
// TODO: What about non-monitored particles (Differentiate?)
}

//! @brief called after Forces are applied
Expand All @@ -166,9 +175,11 @@ void COMaligner::endStep(ParticleContainer *particleContainer, DomainDecompBase
unsigned long simstep, std::list<ChemicalPotential> *lmu,
std::map<unsigned, CavityEnsemble> *mcav) {

for(ParticleIterator tm = particleContainer->iterator(); tm.hasNext(); tm.next()){
for (int d = _dim_start; d < _dim_end; d += _dim_step){
tm->move(d, _motion[d]);
if(_enabled){
for(ParticleIterator tm = particleContainer->iterator(); tm.hasNext(); tm.next()){
for (int d = _dim_start; d < _dim_end; d += _dim_step){
tm->move(d, _motion[d]);
}
}
}
}
17 changes: 17 additions & 0 deletions src/utils/COMaligner.h → src/plugins/COMaligner.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,23 @@
#include "Domain.h"
#include "parallel/DomainDecompBase.h"


//! @brief
//! Plugin: can be enabled via config.xml <br>
//!
//! Calculates Center of mass and moves all particles to align with center of box
//! Individual dimensions X,Y,Z can be toogled on/off for the alignment
//! Alignment happens once every interval-simsteps
//! The correction factor can be set from 0-1
//! 1 being full alignment -> 0 no alignment at all
//!
//! <plugin name="COMaligner">
//! <x>1</x>
//! <y>0</y>
//! <z>1</z>
//! <interval>1</interval>
//! <correctionFactor>.5</correctionFactor>
//! </plugin>
class COMaligner : public PluginBase{

public:
Expand Down
5 changes: 4 additions & 1 deletion src/utils/PluginFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "utils/Logger.h"
#include "utils/String_utils.h"

// Output plugins
#include "io/CavityWriter.h"
#include "io/CheckpointWriter.h"
#include "io/DecompWriter.h"
Expand All @@ -32,7 +33,9 @@
#include "io/VISWriter.h"
#include "io/XyzWriter.h"
#include "io/MaxWriter.h"
#include "utils/COMaligner.h"

// General plugins
#include "plugins/COMaligner.h"
#include "plugins/Mirror.h"

#ifdef VTK
Expand Down

0 comments on commit 39d13dc

Please sign in to comment.