4 #include <boost/algorithm/string.hpp>
26 template <
typename OccType>
45 RemoteHandle(std::string
const &_type_name, std::string
const &_var_name,
191 Index _dof_ID = -1,
int _current_state = 0,
193 :
Base(_traits, _var_name, _dof_ID),
212 "In DiscreteDoF::remote_value() m_remote_state is nullptr.\n");
220 "In DiscreteDoF::register_remote(), attempting to register to "
225 std::unique_ptr<DiscreteDoF>
clone()
const {
226 return std::unique_ptr<DiscreteDoF>(this->
_clone());
239 if (
size() != RHS.
size())
return false;
262 template <
typename T>
267 int _current_state = 0)
276 throw std::runtime_error(
277 "In OccupantDoF::set_value(): Bad Assignment, occ_index>=size.\n");
287 throw std::runtime_error(
288 "In OccupantDoF::set_current_state(): Bad Assignment, new_state not "
289 "found in domain.\n");
298 if (compare_value && (
value() != RHS.
value()))
return false;
300 if (
size() != RHS.
size())
return false;
303 if (!((*
this)[i] == RHS[i]))
return false;
329 void print(std::ostream &out)
const {
338 std::unique_ptr<OccupantDoF>
clone()
const {
339 return std::unique_ptr<OccupantDoF>(
366 :
Base(_traits, _var_name, _ID),
388 "In ContinuousDoF::remote_value() m_remote_val is nullptr.\n");
396 "In ContinuousDoF::register_remote(), attempting to register to "
401 std::unique_ptr<ContinuousDoF>
clone()
const {
402 return notstd::make_unique<ContinuousDoF>(*
this);
Specifies traits of (possibly) anisotropic crystal properties.
std::string const & name() const
Const access of name.
ContinuousDoF(BasicTraits const &_traits)
bool operator==(ContinuousDoF const &RHS) const
double const * m_remote_ptr
Allows DoF to point to a remote value for faster/easier evaluation.
double const * remote_ptr() const
std::unique_ptr< ContinuousDoF > clone() const
double remote_value() const
ContinuousDoF(BasicTraits const &_traits, std::string const &_var_name, Index _ID)
void register_remote(RemoteHandle const &handle) const
bool compare(ContinuousDoF const &RHS, bool compare_value=false) const
void register_remote(RemoteHandle const &handle) const
virtual bool operator==(DiscreteDoF const &RHS) const
void set_symrep_ID(SymGroupRepID _id)
SymGroupRepID m_symrep_ID
ID for the permutation representation for occupants.
virtual Index size() const =0
virtual DiscreteDoF * _clone() const =0
void print(std::ostream &out) const
SymGroupRepID symrep_ID() const
virtual void set_value(int new_state)
bool is_specified() const
int const * m_remote_state
Allows DoF to point to a remote value for faster/easier evaluation.
std::unique_ptr< DiscreteDoF > clone() const
int m_current_state
index into domain of the current state, -1 if unspecified
int const * remote_ptr() const
DiscreteDoF(BasicTraits const &_traits, std::string const &_var_name, Index _dof_ID=-1, int _current_state=0, SymGroupRepID _id=SymGroupRepID::identity(0))
A class that represents an individual Degree of Freedom.
RemoteHandle handle() const
Create a RemoteHandle that refers to this DoF.
void unlock_ID()
mutator to unlock integer ID
Index ID() const
Const access of integer ID.
DoF::RemoteHandle RemoteHandle
BasicTraits const & traits() const
std::string var_name() const
Const access of variable name.
void lock_ID()
mutator to lock integer ID
bool is_locked() const
true if ID is locked
std::string type_name() const
Const access of DoF type name.
bool m_ID_lock
Locks the ID so that it can't be updated. Is used for global DoF's.
void set_ID(Index new_ID)
mutator to set integer ID if it is unlocked
bool operator<(RemoteHandle const &_rhs) const
const double * d_ptr() const
RemoteHandle & operator=(double &&d)=delete
const int * i_ptr() const
RemoteHandle & operator=(int const &i)
RemoteHandle & operator=(double const &d)
RemoteHandle & operator=(int &&i)=delete
RemoteHandle(std::string const &_type_name, std::string const &_var_name, Index _dof_ID)
bool operator==(RemoteHandle const &_rhs) const
void set_current_state(T const &new_state)
Set occupant by value.
const T & operator[](Index i) const
void print(std::ostream &out) const
bool operator==(OccupantDoF const &RHS) const
Equivalent to (*this).compare(RHS,true)
void set_domain(std::vector< T > new_dom)
bool compare(OccupantDoF const &RHS, bool compare_value) const
Returns true if (*this) is equivalent to RHS,.
OccupantDoF(BasicTraits const &_traits, std::string const &_var_name, SymGroupRepID symrep_ID, std::vector< T > const &_domain, int _current_state=0)
const std::vector< T > & domain() const
Index size() const override
std::unique_ptr< OccupantDoF > clone() const
void set_value(int occ_index) override
Set occupant by index.
DiscreteDoF * _clone() const override
std::vector< T > m_domain
Allowed values, assume class T has method 'T.name()()'.
Type-safe ID object for communicating and accessing Symmetry representation info.
static SymGroupRepID identity(Index dim)
Static function to construct an ID for identity representations.
AnisoValTraits BasicTraits
bool almost_equal(ClusterInvariants const &A, ClusterInvariants const &B, double tol)
Check if ClusterInvariants are equal.
Index find_index(Iterator begin, Iterator end, const T &value)
Equivalent to std::distance(begin, std::find(begin, end, value))
bool compare_no_value(ContinuousDoF const &A, ContinuousDoF const &B)
bool valid_index(Index i)
INDEX_TYPE Index
For long integer indexing: