faunus
Public Types | Public Member Functions | Public Attributes | List of all members
Faunus::Group Class Reference

End of Group class. More...

#include <group.h>

Inheritance diagram for Faunus::Group:
Inheritance graph
[legend]
Collaboration diagram for Faunus::Group:
Collaboration graph
[legend]

Public Types

enum  Selectors : unsigned int {
  ANY = (1U << 1U), ACTIVE = (1U << 2U), INACTIVE = (1U << 3U), NEUTRAL = (1U << 4U),
  ATOMIC = (1U << 5U), MOLECULAR = (1U << 6U), FULL = (1U << 7U)
}
 Selections to filter groups using getSelectionFilter() More...
 
using base = ElasticRange< Particle >
 
using iter = typename base::Titer
 
- Public Types inherited from Faunus::ElasticRange< Particle >
using Titer = typename std::vector< Particle >::iterator
 
using const_iterator = typename std::vector< Particle >::const_iterator
 
using base = IterRange< typename std::vector< Particle >::iterator >
 

Public Member Functions

bool isAtomic () const
 Is it an atomic group?
 
bool isMolecular () const
 is it a molecular group?
 
bool isFull () const override
 True of all particles are active.
 
std::optional< std::reference_wrapper< Point > > massCenter ()
 Optional reference to mass center. More...
 
std::optional< std::reference_wrapper< const Point > > massCenter () const
 Optional ref. to mass center.
 
template<unsigned int mask>
bool match () const
 Determines if given Selectors bitmask matches group. More...
 
const MoleculeDatatraits () const
 Convenient access to molecule properties.
 
 Group (Group &other)
 
 Group (const Group &other)
 
 Group (MoleculeData::index_type molid, iter begin, iter end)
 Constructor. More...
 
Groupoperator= (const Group &other)
 Deep copy contents from another Group. More...
 
GroupshallowCopy (const Group &other)
 copy from other but not particle data More...
 
bool contains (const Particle &particle, bool include_inactive=false) const
 Does particle belong?
 
double mass () const
 Sum of all active masses.
 
auto positions ()
 Range of positions of active particles.
 
auto positions () const
 Range of positions of active particles.
 
AtomData::index_type getParticleIndex (const Particle &particle, bool include_inactive=false) const
 Finds index of particle within group. Throws if not part of group.
 
auto findAtomID (AtomData::index_type atomid) const
 Range of all (active) elements with matching particle id.
 
auto & operator[] (size_t index)
 Returns i'th element in group. More...
 
const auto & operator[] (size_t index) const
 
Particleat (size_t index)
 Returns i'th element in group. More...
 
const Particleat (size_t index) const
 Returns i'th element in group. More...
 
template<std::integral Tint = size_t>
auto operator[] (std::vector< Tint > &indices)
 Reference to subset of given indices, where 0 is the start of the group. More...
 
template<typename TdistanceFunc >
void unwrap (const TdistanceFunc &vector_distance)
 Remove PBC for molecular groups w. More...
 
void wrap (Geometry::BoundaryFunction boundary)
 Apply periodic boundaries (Order N complexity).
 
void translate (const Point &displacement, Geometry::BoundaryFunction boundary=[](Point &) { })
 Translate particle positions and mass center.
 
void rotate (const Eigen::Quaterniond &quaternion, Geometry::BoundaryFunction boundary)
 Rotate particles incl. internal coordinates (dipole moment etc.)
 
void updateMassCenter (Geometry::BoundaryFunction boundary, const Point &approximate_mass_center)
 Calculates mass center. More...
 
void updateMassCenter (Geometry::BoundaryFunction boundary)
 Calculates mass center. More...
 
- Public Member Functions inherited from Faunus::ElasticRange< Particle >
 ElasticRange (Titer begin, Titer end)
 
size_t capacity () const
 
auto inactive () const
 Range of inactive elements.
 
void deactivate (Titer first, Titer last)
 Deactivate particles by moving to end, reducing the effective size.
 
void activate (Titer first, Titer last)
 Activate previously deactivated elements.
 
Titer & trueend ()
 
const Titer & trueend () const
 
void relocate (const_iterator oldorigin, Titer neworigin)
 Shift all iterators to new underlying container; useful when resizing vectors.
 
auto numInactive () const
 Number of inactive elements. More...
 
bool resizeIsPossible (int number_to_insert_or_delete) const
 
auto all ()
 Active and inactive elements.
 
auto all () const
 Active and inactive elements.
 
- Public Member Functions inherited from Faunus::IterRange< std::vector< Particle >::iterator >
std::vector< Particle >::iterator & begin ()
 
const std::vector< Particle >::iterator & begin () const
 
std::vector< Particle >::iterator & end ()
 
const std::vector< Particle >::iterator & end () const
 
size_t size () const
 
void resize (size_t n)
 
bool empty () const
 
void clear ()
 
std::pair< int, int > to_index (std::vector< Particle >::iterator reference) const
 Returns particle index pair relative to given reference.
 

Public Attributes

int id = -1
 Molecule id.
 
int conformation_id = 0
 Conformation index / id.
 
Point mass_center = {0.0, 0.0, 0.0}
 Mass center.
 

Detailed Description

End of Group class.

Member Enumeration Documentation

◆ Selectors

enum Faunus::Group::Selectors : unsigned int

Selections to filter groups using getSelectionFilter()

Enumerator
ANY 

Match any group (disregards all other flags)

ACTIVE 

Only active groups (non-zero size)

INACTIVE 

Only inactive groups (zero size)

NEUTRAL 

Only groups with zero net charge.

ATOMIC 

Only atomic groups.

MOLECULAR 

Only molecular groups (atomic=false)

FULL 

Only groups where size equals capacity.

Constructor & Destructor Documentation

◆ Group()

Faunus::Group::Group ( MoleculeData::index_type  molid,
Group::iter  begin,
Group::iter  end 
)

Constructor.

Parameters
molidMolecule id the group points to, i.e. a valid index in global Faunus::molecules.
beginIterator to first particle
endIterator to (beyond) end particle
Exceptions
ifmolid is out of range w. respect to Faunus::molecules

Member Function Documentation

◆ at() [1/2]

Particle & Faunus::Group::at ( size_t  index)

Returns i'th element in group.

Parameters
indexindex starting at zero
Returns
reference to value at i'th element
Exceptions
ifout of interval [0:capacity[

◆ at() [2/2]

const Particle & Faunus::Group::at ( size_t  index) const

Returns i'th element in group.

Parameters
indexindex starting at zero
Returns
reference to value at i'th element
Exceptions
ifout of interval [0:capacity[

◆ massCenter()

std::optional< std::reference_wrapper< Point > > Faunus::Group::massCenter ( )

Optional reference to mass center.

If the group supports mass centers (i.e.

molecular groups), an optional reference will be returned. Example usage:

if (auto mass_center = group.massCenter()) { (*mass_center).get() = Point(0,1,2); }

Returns
Optional reference to stored group mass center

◆ match()

template<unsigned int mask>
bool Faunus::Group::match ( ) const
inline

Determines if given Selectors bitmask matches group.

Template Parameters
maskBitmask build from enum Group::Selectors
Returns
true if ALL enabled bits in the mask are satisfied

Note that for INACTIVE | NEUTRAL, the criterion is applied to all active and inactive particles, i.e. until trueend().

◆ operator=()

Group & Faunus::Group::operator= ( const Group other)

Deep copy contents from another Group.

Performs a deep copy from another group.

Exceptions
ifthe capacities of the two groups differ

◆ operator[]() [1/2]

auto& Faunus::Group::operator[] ( size_t  index)
inline

Returns i'th element in group.

Parameters
iindex starting at zero
Returns
reference to value at i'th element
Note
No range-checking and i must be in interval [0:size[

◆ operator[]() [2/2]

template<std::integral Tint = size_t>
auto Faunus::Group::operator[] ( std::vector< Tint > &  indices)
inline

Reference to subset of given indices, where 0 is the start of the group.

Parameters
indicesRange of indices relative to group
Warning
Do not change indices to const& which would create a dangling reference

◆ shallowCopy()

Group & Faunus::Group::shallowCopy ( const Group other)

copy from other but not particle data

This copies size, id, mass center etc.

from another group but does not copy particle data.

Exceptions
ifthe capacities of the two groups differ

◆ unwrap()

template<typename TdistanceFunc >
void Faunus::Group::unwrap ( const TdistanceFunc &  vector_distance)
inline

Remove PBC for molecular groups w.

respect to mass center

Template Parameters
TdistanceFunc
Parameters
vector_distanceDistance calculation function
Remarks
Atomic groups are not touched
Warning
Is this fit for use?

◆ updateMassCenter() [1/2]

void Faunus::Group::updateMassCenter ( Geometry::BoundaryFunction  boundary_function,
const Point approximate_mass_center 
)

Calculates mass center.

Parameters
boundary_functionFunction to apply periodic boundaries
approximate_mass_centerOriginal or appriximate mass center used for PBC removal

Only active, molecular groups are affected. Before the mass center is calculated, the molecule is translated towards the center of the simulation box to remove possible periodic boundary conditions; then translated back again. The translation is done by subtracting / adding approximate_mass_center. Safely handles empty groups.

◆ updateMassCenter() [2/2]

void Faunus::Group::updateMassCenter ( Geometry::BoundaryFunction  boundary_function)

Calculates mass center.

Parameters
boundary_functionFunction to apply periodic boundaries

This will approximate the existing mass center by the middle particle which for PBC systems is generally safer then using the old mass center.


The documentation for this class was generated from the following files: