LCOV - code coverage report
Current view: top level - core - PbcAction.cpp (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 26 26 100.0 %
Date: 2024-10-18 14:00:25 Functions: 5 6 83.3 %

          Line data    Source code
       1             : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
       2             :    Copyright (c) 2011-2023 The plumed team
       3             :    (see the PEOPLE file at the root of the distribution for a list of names)
       4             : 
       5             :    See http://www.plumed.org for more information.
       6             : 
       7             :    This file is part of plumed, version 2.
       8             : 
       9             :    plumed is free software: you can redistribute it and/or modify
      10             :    it under the terms of the GNU Lesser General Public License as published by
      11             :    the Free Software Foundation, either version 3 of the License, or
      12             :    (at your option) any later version.
      13             : 
      14             :    plumed is distributed in the hope that it will be useful,
      15             :    but WITHOUT ANY WARRANTY; without even the implied warranty of
      16             :    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      17             :    GNU Lesser General Public License for more details.
      18             : 
      19             :    You should have received a copy of the GNU Lesser General Public License
      20             :    along with plumed.  If not, see <http://www.gnu.org/licenses/>.
      21             : +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
      22             : #include "PbcAction.h"
      23             : #include "DomainDecomposition.h"
      24             : #include "tools/Pbc.h"
      25             : #include "PlumedMain.h"
      26             : #include "ActionSet.h"
      27             : #include "ActionRegister.h"
      28             : 
      29             : //+PLUMEDOC ANALYSIS PBC
      30             : /*
      31             : Pass the cell vectors into PLUMED.
      32             : 
      33             : \par Examples
      34             : 
      35             : */
      36             : //+ENDPLUMEDOC
      37             : 
      38             : namespace PLMD {
      39             : 
      40             : PLUMED_REGISTER_ACTION(PbcAction,"PBC")
      41             : 
      42        1202 : void PbcAction::registerKeywords( Keywords& keys ) {
      43        1202 :   Action::registerKeywords( keys );
      44        2404 :   keys.add("hidden","NO_ACTION_LOG","suppresses printing from action on the log");
      45        1202 :   keys.setValueDescription("a matrix containing the cell vectors that were passed from the MD code");
      46        1202 : }
      47             : 
      48        1195 : PbcAction::PbcAction(const ActionOptions&ao):
      49             :   Action(ao),
      50             :   ActionToPutData(ao),
      51        1195 :   interface(NULL)
      52             : {
      53        1195 :   std::vector<unsigned> shape(2); shape[0]=shape[1]=3;
      54        2390 :   addValue( shape ); setNotPeriodic(); setUnit( "length", "energy" );
      55        1195 :   getPntrToValue()->buildDataStore(); getPntrToValue()->reshapeMatrixStore(3);
      56        1195 : }
      57             : 
      58             : 
      59       66603 : void PbcAction::setPbc() {
      60       66603 :   if( !interface ) {
      61         992 :     std::vector<DomainDecomposition*> allput=plumed.getActionSet().select<DomainDecomposition*>();
      62         992 :     if( allput.size()>1 ) warning("found more than one interface so don't know how to broadcast cell");
      63         992 :     interface = allput[0];
      64             :   }
      65       66603 :   Tensor box; if( interface ) interface->broadcastToDomains( getPntrToValue() );
      66      865839 :   for(unsigned i=0; i<3; ++i) for(unsigned j=0; j<3; ++j) box(i,j) = getPntrToValue()->get(3*i+j);
      67       66603 :   pbc.setBox(box);
      68       66603 : }
      69             : 
      70       66489 : void PbcAction::wait() {
      71       66489 :   ActionToPutData::wait(); setPbc();
      72       66489 : }
      73             : 
      74         114 : void PbcAction::readBinary(std::istream&i) {
      75         114 :   ActionToPutData::readBinary(i); setPbc();
      76         114 : }
      77             : 
      78             : }
      79             : 
      80             : 
      81             : 

Generated by: LCOV version 1.16