33 siteMasses_(
List<scalar>(0)),
34 siteCharges_(
List<scalar>(0)),
36 pairPotentialSites_(
List<bool>(false)),
37 electrostaticSites_(
List<bool>(false)),
48 siteReferencePositions_(
dict.lookup(
"siteReferencePositions")),
49 siteMasses_(
dict.lookup(
"siteMasses")),
50 siteCharges_(
dict.lookup(
"siteCharges")),
52 pairPotentialSites_(),
53 electrostaticSites_(),
59 setInteractionSiteBools
65 mass_ =
sum(siteMasses_);
72 forAll(siteReferencePositions_, i)
74 centreOfMass += siteReferencePositions_[i]*siteMasses_[i];
77 centreOfMass /= mass_;
79 siteReferencePositions_ -= centreOfMass;
81 if (siteIds_.
size() == 1)
85 siteReferencePositions_[0] =
Zero;
89 else if (linearMoleculeTest())
95 vector dir = siteReferencePositions_[1] - siteReferencePositions_[0];
101 siteReferencePositions_ = (
Q & siteReferencePositions_);
108 forAll(siteReferencePositions_, i)
110 centreOfMass += siteReferencePositions_[i]*siteMasses_[i];
113 centreOfMass /= mass_;
115 siteReferencePositions_ -= centreOfMass;
119 forAll(siteReferencePositions_, i)
121 const vector&
p(siteReferencePositions_[i]);
142 forAll(siteReferencePositions_, i)
144 const vector&
p(siteReferencePositions_[i]);
146 momOfInertia += siteMasses_[i]*
tensor
148 p.y()*
p.y() +
p.z()*
p.z(), -
p.x()*
p.y(), -
p.x()*
p.z(),
149 -
p.y()*
p.x(),
p.x()*
p.x() +
p.z()*
p.z(), -
p.y()*
p.z(),
150 -
p.z()*
p.x(), -
p.z()*
p.y(),
p.x()*
p.x() +
p.y()*
p.y()
157 <<
"An eigenvalue of the inertia tensor is zero, the molecule "
158 <<
dict.name() <<
" is not a valid 6DOF shape."
177 siteReferencePositions_ = (
Q & siteReferencePositions_);
186 forAll(siteReferencePositions_, i)
188 centreOfMass += siteReferencePositions_[i]*siteMasses_[i];
191 centreOfMass /= mass_;
193 siteReferencePositions_ -= centreOfMass;
200 forAll(siteReferencePositions_, i)
202 const vector&
p(siteReferencePositions_[i]);
204 momOfInertia += siteMasses_[i]*
tensor
206 p.y()*
p.y() +
p.z()*
p.z(), -
p.x()*
p.y(), -
p.x()*
p.z(),
207 -
p.y()*
p.x(),
p.x()*
p.x() +
p.z()*
p.z(), -
p.y()*
p.z(),
208 -
p.z()*
p.x(), -
p.z()*
p.y(),
p.x()*
p.x() +
p.y()*
p.y()
227 label& nLocateBoundaryHits,
247 potentialEnergy_(0.0),
251 siteForces_(constProps.nSites(),
Zero),
252 sitePositions_(constProps.nSites())
260 inline void Foam::molecule::constantProperties::checkSiteListSizes()
const
264 siteIds_.size() != siteReferencePositions_.size()
265 || siteIds_.size() != siteCharges_.size()
269 <<
"Sizes of site id, charge and "
270 <<
"referencePositions are not the same. "
276 inline void Foam::molecule::constantProperties::setInteractionSiteBools
278 const List<word>& siteIds,
279 const List<word>& pairPotSiteIds
282 pairPotentialSites_.setSize(siteIds_.size());
284 electrostaticSites_.setSize(siteIds_.size());
288 const word& id(siteIds[i]);
290 pairPotentialSites_[i] = (
findIndex(pairPotSiteIds,
id) > -1);
292 electrostaticSites_[i] = (
mag(siteCharges_[i]) > vSmall);
297 inline bool Foam::molecule::constantProperties::linearMoleculeTest()
const
299 if (siteIds_.size() == 2)
304 vector refDir = siteReferencePositions_[1] - siteReferencePositions_[0];
306 refDir /=
mag(refDir);
311 i < siteReferencePositions_.size();
315 vector dir = siteReferencePositions_[i] - siteReferencePositions_[i-1];
319 if (
mag(refDir & dir) < 1 - small)
334 return siteReferencePositions_;
369 return pairPotentialSites_;
383 << sId <<
" site not found."
387 return pairPotentialSites_[
s];
394 return electrostaticSites_;
408 << sId <<
" site not found."
412 return electrostaticSites_[
s];
419 return momentOfInertia_;
425 return ((momentOfInertia_.xx() < 0) && (momentOfInertia_.yy() > 0));
431 return (momentOfInertia_.zz() < 0);
437 if (linearMolecule())
441 else if (pointMolecule())
460 return siteIds_.size();
541 return sitePositions_;
547 return sitePositions_;
553 return specialPosition_;
559 return specialPosition_;
565 return potentialEnergy_;
571 return potentialEnergy_;
595 return special_ == SPECIAL_TETHERED;
#define forAll(list, i)
Loop across all elements in list.
Pre-declare SubField and related Field type.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void size(const label)
Override size to be inconsistent with allocated storage.
A list of keyword definitions, which are a keyword followed by any number of values (e....
Class to hold molecule constant properties.
const diagTensor & momentOfInertia() const
bool pointMolecule() const
const Field< vector > & siteReferencePositions() const
const List< label > & siteIds() const
const List< bool > & pairPotentialSites() const
const List< scalar > & siteCharges() const
bool pairPotentialSite(label sId) const
bool electrostaticSite(label sId) const
label degreesOfFreedom() const
const List< scalar > & siteMasses() const
const List< bool > & electrostaticSites() const
bool linearMolecule() const
molecule(const polyMesh &mesh, const vector &position, const label celli, label &nLocateBoundaryHits, const tensor &Q, const vector &v, const vector &a, const vector &pi, const vector &tau, const vector &specialPosition, const constantProperties &constProps, const label special, const label id)
Construct from a position and a cell, searching for the rest of the.
const List< vector > & sitePositions() const
const List< vector > & siteForces() const
const vector & specialPosition() const
void setSitePositions(const polyMesh &mesh, const constantProperties &constProps)
const tensor & rf() const
const vector & tau() const
scalar potentialEnergy() const
const vector & pi() const
vector position(const polyMesh &mesh) const
Return current particle position.
Mesh consisting of general polyhedral cells.
A class for handling words, derived from string.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.name(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
tensor rotationTensor(const vector &n1, const vector &n2)
Rotational transformation tensor from unit vector n1 to n2.
dimensionedTensor eigenVectors(const dimensionedTensor &dt)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Tensor< scalar > tensor
Tensor of scalars.
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
errorManip< error > abort(error &err)
DiagTensor< scalar > diagTensor
A scalar version of the templated DiagTensor.
Vector< scalar > vector
A scalar version of the templated Vector.
dimensioned< scalar > mag(const dimensioned< Type > &)
dimensionedVector eigenValues(const dimensionedTensor &dt)
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurrence of given element and return index,.