Gromacs  2026.0-dev-20241212-74b8831
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Typedefs | Enumerations | Functions
vsite.cpp File Reference
#include "gmxpre.h"
#include "vsite.h"
#include <cstdio>
#include <algorithm>
#include <filesystem>
#include <memory>
#include <vector>
#include "gromacs/domdec/domdec.h"
#include "gromacs/domdec/domdec_struct.h"
#include "gromacs/gmxlib/network.h"
#include "gromacs/gmxlib/nrnb.h"
#include "gromacs/math/functions.h"
#include "gromacs/math/vec.h"
#include "gromacs/mdlib/gmx_omp_nthreads.h"
#include "gromacs/mdtypes/commrec.h"
#include "gromacs/mdtypes/md_enums.h"
#include "gromacs/pbcutil/ishift.h"
#include "gromacs/pbcutil/pbc.h"
#include "gromacs/timing/wallcycle.h"
#include "gromacs/topology/block.h"
#include "gromacs/topology/forcefieldparameters.h"
#include "gromacs/topology/ifunc.h"
#include "gromacs/topology/mtop_util.h"
#include "gromacs/topology/topology.h"
#include "gromacs/topology/topology_enums.h"
#include "gromacs/utility/arrayref.h"
#include "gromacs/utility/basedefinitions.h"
#include "gromacs/utility/exceptions.h"
#include "gromacs/utility/fatalerror.h"
#include "gromacs/utility/gmxassert.h"
#include "gromacs/utility/gmxomp.h"
+ Include dependency graph for vsite.cpp:

Description

Implements the VirtualSitesHandler class and vsite standalone functions.

Author
Berk Hess hess@.nosp@m.kth..nosp@m.se

Classes

struct  gmx::DomainInfo
 Information on PBC and domain decomposition for virtual sites. More...
 
struct  gmx::AtomIndex
 List of atom indices belonging to a task. More...
 
struct  gmx::InterdependentTask
 Data structure for thread tasks that use constructing atoms outside their own atom range. More...
 
struct  gmx::VsiteThread
 Vsite thread task data structure. More...
 
class  gmx::ThreadingInfo
 Information on how the virtual site work is divided over thread tasks. More...
 
class  gmx::VirtualSitesHandler::Impl
 Impl class for VirtualSitesHandler. More...
 

Typedefs

using gmx::VirialHandling = VirtualSitesHandler::VirialHandling
 VirialHandling is often used outside VirtualSitesHandler class members.
 

Enumerations

enum  gmx::VSiteCalculatePosition { Yes, No }
 Whether we're calculating the virtual site position.
 
enum  gmx::VSiteCalculateVelocity { Yes, No }
 Whether we're calculating the virtual site velocity.
 
enum  gmx::PbcMode { gmx::PbcMode::all, gmx::PbcMode::none }
 PBC modes for vsite construction and spreading. More...
 

Functions

static int gmx::vsiteIlistNrCount (ArrayRef< const InteractionList > ilist)
 Returns the sum of the vsite ilist sizes over all vsite types. More...
 
static int gmx::pbc_rvec_sub (const t_pbc *pbc, const rvec xi, const rvec xj, rvec dx)
 Computes the distance between xi and xj, pbc is used when pbc!=nullptr.
 
static real gmx::inverseNorm (const rvec x)
 Returns the 1/norm(x)
 
static PbcMode gmx::getPbcMode (const t_pbc *pbcPtr)
 Returns the PBC mode based on the system PBC and vsite properties. More...
 
template<VSiteCalculatePosition calculatePosition, VSiteCalculateVelocity calculateVelocity>
static void gmx::construct_vsites_thread (ArrayRef< RVec > x, ArrayRef< RVec > v, ArrayRef< const t_iparams > ip, ArrayRef< const InteractionList > ilist, const t_pbc *pbc_null)
 Executes the vsite construction task for a single thread. More...
 
template<VSiteCalculatePosition calculatePosition, VSiteCalculateVelocity calculateVelocity>
static void gmx::construct_vsites (const ThreadingInfo *threadingInfo, ArrayRef< RVec > x, ArrayRef< RVec > v, ArrayRef< const t_iparams > ip, ArrayRef< const InteractionList > ilist, const DomainInfo &domainInfo, const matrix box)
 Dispatch the vsite construction tasks for all threads. More...
 
void gmx::constructVirtualSites (ArrayRef< RVec > x, ArrayRef< const t_iparams > ip, ArrayRef< const InteractionList > ilist)
 Create positions of vsite atoms based for the local system. More...
 
static int gmx::vsite_count (ArrayRef< const InteractionList > ilist, int ftype)
 Returns the number of virtual sites in the interaction list, for VSITEN the number of atoms.
 
template<VirialHandling virialHandling>
static void gmx::spreadForceForThread (ArrayRef< const RVec > x, ArrayRef< RVec > f, ArrayRef< RVec > fshift, matrix dxdf, ArrayRef< const t_iparams > ip, ArrayRef< const InteractionList > ilist, const t_pbc *pbc_null)
 Executes the force spreading task for a single thread.
 
static void gmx::spreadForceWrapper (ArrayRef< const RVec > x, ArrayRef< RVec > f, const VirialHandling virialHandling, ArrayRef< RVec > fshift, matrix dxdf, const bool clearDxdf, ArrayRef< const t_iparams > ip, ArrayRef< const InteractionList > ilist, const t_pbc *pbc_null)
 Wrapper function for calling the templated thread-local spread function.
 
static void gmx::clearTaskForceBufferUsedElements (InterdependentTask *idTask)
 Clears the task force buffer elements that are written by task idTask.
 
static std::vector< int > gmx::makeAtomToGroupMapping (const gmx::RangePartitioning &grouping)
 Returns the an array with group indices for each atom. More...
 
int gmx::countNonlinearVsites (const gmx_mtop_t &mtop)
 Return the number of non-linear virtual site constructions in the system.
 
int gmx::countInterUpdategroupVsites (const gmx_mtop_t &mtop, ArrayRef< const RangePartitioning > updateGroupingsPerMoleculeType)
 Return the number of virtual sites that cross update groups. More...
 
std::unique_ptr
< VirtualSitesHandler > 
gmx::makeVirtualSitesHandler (const gmx_mtop_t &mtop, const t_commrec *cr, PbcType pbcType, ArrayRef< const RangePartitioning > updateGroupingPerMoleculeType)
 Create the virtual site handler. More...
 
 gmx::iparams_ (mtop.ffparams.iparams)
 
static void gmx::flagAtom (InterdependentTask *idTask, const int atom, const int numThreads, const int numAtomsPerThread)
 Flag that atom atom which is home in another task, if it has not already been added before.
 
static void gmx::assignVsitesToThread (VsiteThread *tData, int thread, int nthread, int natperthread, gmx::ArrayRef< int > taskIndex, ArrayRef< const InteractionList > ilist, ArrayRef< const t_iparams > ip, ArrayRef< const ParticleType > ptype)
 Here we try to assign all vsites that are in our local range. More...
 
static void gmx::assignVsitesToSingleTask (VsiteThread *tData, int task, gmx::ArrayRef< const int > taskIndex, ArrayRef< const InteractionList > ilist, ArrayRef< const t_iparams > ip)
 Assign all vsites with taskIndex[]==task to task tData.