atomicrex  0.1
An advanced atomistic model building tool
AtomVectorProperty.h
1 //
3 // Copyright (C) 2017, Alexander Stukowski and Paul Erhart
4 //
5 // This file is part of atomicrex.
6 //
7 // Atomicrex is free software; you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation; either version 3 of the License, or
10 // (at your option) any later version.
11 //
12 // Atomicrex is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
19 //
21 
22 #pragma once
23 
24 #include "FitProperty.h"
25 
26 namespace atomicrex {
27 
33 {
34 public:
35 
38 
41  FitProperty(id, units, job) {}
42 
44  bool outputAllEnabled() const { return _outputAllEnabled; }
45 
47  void setOutputAllEnabled(bool enable) { _outputAllEnabled = enable; }
48 
50  void setAtomCount(int numAtoms) {
51  if(numAtoms != _computedValues.size()) {
52  _computedValues.resize(numAtoms, Vector3::Zero());
53  _targetValues.resize(numAtoms, Vector3::Zero());
54  _hasTargetValues = false;
55  }
56  };
57 
59  int atomCount() { return _computedValues.size(); };
60 
62  virtual double residual(ResidualNorm norm) const override;
63 
65  void setTargetValue(int atomIndex, const Vector3& value) {
66  BOOST_ASSERT(atomIndex >= 0 && atomIndex < _targetValues.size());
67  _targetValues[atomIndex] = value;
68  _hasTargetValues = true;
69  };
70 
72  const std::vector<Vector3>& values() const { return _computedValues; }
73 
75  std::vector<Vector3>& values() { return _computedValues; }
76 
78  std::vector<Vector3>& targetValues() { return _targetValues; }
79  const std::vector<Vector3>& targetValues() const { return _targetValues; }
80 
82  virtual void print(MsgLogger& stream) override;
83 
84 public:
85 
87  virtual void parse(XML::Element propertyElement) override;
88 
89 protected:
90 
92  std::vector<Vector3> _computedValues;
93 
95  std::vector<Vector3> _targetValues;
96 
98  bool _outputAllEnabled = false;
99 
101  bool _hasTargetValues = false;
102 };
103 
104 } // End of namespace
Definition: Logger.h:37
void setTargetValue(int atomIndex, const Vector3 &value)
Set the target values.
Definition: AtomVectorProperty.h:65
std::vector< Vector3 > & targetValues()
Returns the target values of the vector property.
Definition: AtomVectorProperty.h:78
virtual void parse(XML::Element propertyElement) override
Parse the contents of the <property> element in the job file.
Definition: AtomVectorProperty.cpp:139
std::vector< Vector3 > _computedValues
This holds the computed values for the property.
Definition: AtomVectorProperty.h:92
void setAtomCount(int numAtoms)
Allocates memory to store the property values for the given number of atoms (without ghost atoms)...
Definition: AtomVectorProperty.h:50
std::vector< Vector3 > & values()
Returns the current computed values of the vector property.
Definition: AtomVectorProperty.h:75
std::vector< Vector3 > _targetValues
The target values.
Definition: AtomVectorProperty.h:95
const std::vector< Vector3 > & values() const
Returns the current computed values of the vector property.
Definition: AtomVectorProperty.h:72
Definition: FitProperty.h:38
bool _outputAllEnabled
Controls whether all elements of the vector are to printed if output is enabled.
Definition: AtomVectorProperty.h:98
This file collects the definition of classes that define various simple crystal structures.
Definition: Atomicrex.h:67
bool _hasTargetValues
Indicates that the target values have been set for this fit property.
Definition: AtomVectorProperty.h:101
bool outputAllEnabled() const
Returns whether this property is calculated and displayed at the end of the fitting process...
Definition: AtomVectorProperty.h:44
std::string FPString
The default string type used throughout the code:
Definition: Atomicrex.h:70
Definition: XMLUtilities.h:69
int atomCount()
Retrieve number of atoms.
Definition: AtomVectorProperty.h:59
Definition: FitJob.h:37
FitJob * job() const
Returns a pointer to the job to which this object belongs.
Definition: FitObject.h:150
virtual double residual(ResidualNorm norm) const override
Returns the residual of this property used for fitting.
Definition: AtomVectorProperty.cpp:34
const FPString & units() const
Returns the units of this property.
Definition: FitProperty.h:93
virtual void print(MsgLogger &stream) override
Outputs the current value of the property.
Definition: AtomVectorProperty.cpp:75
void setOutputAllEnabled(bool enable)
Sets whether this property is calculated and displayed at the end of the fitting process.
Definition: AtomVectorProperty.h:47
AtomVectorProperty(const FPString &id, const FPString &units, FitJob *job)
Initialization constructor.
Definition: AtomVectorProperty.h:40
ResidualNorm
Specifies how residual contributions are calculated.
Definition: FitProperty.h:43
AtomVectorProperty()
Default constructor.
Definition: AtomVectorProperty.h:37
Definition: AtomVectorProperty.h:32