Created
December 10, 2014 10:16
-
-
Save saifthe1/327e175938eda7afe229 to your computer and use it in GitHub Desktop.
PolyMoleculeCloud class creating instances of polyMolecule class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class polyMoleculeCloud; | |
/*---------------------------------------------------------------------------*\ | |
Class polyMolecule Declaration | |
\*---------------------------------------------------------------------------*/ | |
class polyMolecule | |
: | |
public particle | |
{ | |
public: | |
// Values of special that are less than zero are for built-in functionality. | |
// Values greater than zero are user specifiable/expandable (i.e. test | |
// special_ >= SPECIAL_USER) | |
enum specialTypes | |
{ | |
SPECIAL_TETHERED = -1, | |
SPECIAL_FROZEN = -2, | |
NOT_SPECIAL = 0, | |
SPECIAL_USER = 1 | |
}; | |
//- Class to hold molecule constant properties | |
class constantProperties | |
{ | |
// Private data | |
label nSites_; | |
List<constPropSite> sites_; | |
List<label> electrostaticSites_; | |
List<label> pairPotSites_; | |
diagTensor momentOfInertia_; | |
scalar mass_; | |
// Private Member Functions | |
void checkSiteListSizes() const; | |
void setInteracionSiteBools | |
( | |
const List<word>& siteIds, | |
const List<word>& pairPotSiteIds | |
); | |
bool linearMoleculeTest() const; | |
public: | |
inline constantProperties(); | |
//- Construct from dictionary | |
inline constantProperties | |
( | |
const dictionary& dict, | |
const reducedUnits& rU, | |
const labelList& siteIds | |
); | |
// Member functions | |
inline const List<constPropSite>& sites() const; | |
inline const List<label>& pairPotSites() const; | |
inline const List<label>& electrostaticSites() const; | |
inline const diagTensor& momentOfInertia() const; | |
inline bool linearMolecule() const; | |
inline bool pointMolecule() const; | |
inline label degreesOfFreedom() const; | |
inline scalar mass() const; | |
inline label nSites() const; | |
}; | |
//- Class used to pass tracking data to the trackToFace function | |
class trackingData | |
: | |
public particle::TrackingData<polyMoleculeCloud> | |
{ | |
// label specifying which part of the integration algorithm is taking | |
label part_; | |
public: | |
// Constructors | |
trackingData(polyMoleculeCloud& cloud, label part) | |
: | |
particle::TrackingData<polyMoleculeCloud>(cloud), | |
part_(part) | |
{} | |
// Member functions | |
inline label part() const | |
{ | |
return part_; | |
} | |
}; | |
private: | |
// Private data | |
//- Be careful with the ordering of data. | |
// It has an impact on binary transfer: | |
// -# Put the largest data members 1st | |
// -# Pair up labels, | |
// -# Don't go scalar-label, scalar-label, because in 64bit mode, | |
// the labels will be padded by 4bytes. | |
tensor Q_; | |
//- linear velocity | |
vector v_; | |
//- linear acceleration | |
vector a_; | |
//- angular momentum | |
vector pi_; | |
//- torque | |
vector tau_; | |
vector specialPosition_; | |
scalar potentialEnergy_; | |
// - r_ij f_ij, stress dyad | |
tensor rf_; | |
// // - r_ij outer product f_ij: virial contribution | |
// tensor rDotf_; | |
label special_; | |
label id_; | |
scalar R_; | |
// - fraction of force potential contribution | |
scalar frac_; | |
//- each molecule will have a unique label | |
label trackingNumber_; | |
List<vector> siteForces_; | |
List<vector> sitePositions_; | |
// Private Member Functions | |
tensor rotationTensorX(scalar deltaT) const; | |
tensor rotationTensorY(scalar deltaT) const; | |
tensor rotationTensorZ(scalar deltaT) const; | |
public: | |
friend class Cloud<polyMolecule>; | |
// Constructors | |
//- Construct from components | |
inline polyMolecule | |
( | |
// const Cloud<polyMolecule>& c, | |
const polyMesh& mesh, | |
const vector& position, | |
const label cellI, | |
const label tetFaceI, | |
const label tetPtI, | |
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, | |
const scalar& frac, | |
const label trackingNumber | |
); | |
//- Construct from Istream | |
polyMolecule | |
( | |
// const Cloud<polyMolecule>& c, | |
const polyMesh& mesh, | |
Istream& is, | |
bool readFields = true | |
); | |
autoPtr<particle> clone() const | |
{ | |
return autoPtr<particle>(new polyMolecule(*this)); | |
} | |
//- Factory class to read-construct particles used for | |
// parallel transfer | |
class iNew | |
{ | |
const polyMesh& mesh_; | |
public: | |
iNew(const polyMesh& mesh) | |
: | |
mesh_(mesh) | |
{} | |
autoPtr<polyMolecule> operator()(Istream& is) const | |
{ | |
return autoPtr<polyMolecule>(new polyMolecule(mesh_, is, true)); | |
} | |
}; | |
// Member Functions | |
// Tracking | |
bool move(trackingData&, const scalar& trackTime); | |
void transformProperties(const tensor& T); | |
void transformProperties(const vector& separation); | |
void setSitePositions(const constantProperties& constProps); | |
void setSiteSizes(label size); | |
void updateHalfVelocity | |
( | |
const constantProperties& constProps, | |
const scalar& trackTime | |
); | |
void updateAcceleration | |
( | |
const constantProperties& constProps | |
); | |
void updateAfterMove | |
( | |
const constantProperties& constProps, | |
const scalar& trackTime | |
); | |
// Access | |
inline const tensor& Q() const; | |
inline tensor& Q(); | |
inline const vector& v() const; | |
inline vector& v(); | |
inline const vector& a() const; | |
inline vector& a(); | |
inline const vector& pi() const; | |
inline vector& pi(); | |
inline const vector& tau() const; | |
inline vector& tau(); | |
inline const List<vector>& siteForces() const; | |
inline List<vector>& siteForces(); | |
inline const List<vector>& sitePositions() const; | |
inline List<vector>& sitePositions(); | |
inline const vector& specialPosition() const; | |
inline vector& specialPosition(); | |
inline scalar potentialEnergy() const; | |
inline scalar& potentialEnergy(); | |
inline const tensor& rf() const; | |
inline tensor& rf(); | |
// - Return virial contribution | |
// inline const tensor& rDotf() const; | |
// inline tensor& rDotf(); | |
inline label special() const; | |
inline bool tethered() const; | |
inline label id() const; | |
inline label& id(); | |
// - return shortest radius | |
inline const scalar& R() const; | |
inline scalar& R(); | |
inline const scalar& fraction() const; | |
inline scalar& fraction(); | |
// - return tracking number | |
inline const label& trackingNumber() const; | |
inline label& trackingNumber(); | |
inline bool frozen(); | |
//- Overridable function to handle the particle hitting a patch | |
// Executed before other patch-hitting functions | |
bool hitPatch | |
( | |
const polyPatch&, | |
trackingData& td, | |
const label patchI, | |
const scalar trackFraction, | |
const tetIndices& tetIs | |
); | |
//- Overridable function to handle the particle hitting a processorPatch | |
void hitProcessorPatch | |
( | |
const processorPolyPatch&, | |
trackingData& td | |
); | |
//- Overridable function to handle the particle hitting a wallPatch | |
void hitWallPatch | |
( | |
const wallPolyPatch&, | |
trackingData& td, | |
const tetIndices& | |
); | |
//- Overridable function to handle the particle hitting a polyPatch | |
void hitPatch | |
( | |
const polyPatch&, | |
trackingData& td | |
); | |
}; | |
/*---------------------------------------------------------------------------*\ | |
Class polyMoleculeCloud Declaration | |
\*---------------------------------------------------------------------------*/ | |
class polyMoleculeCloud | |
: | |
public Cloud<polyMolecule> | |
{ | |
private: | |
// Private data | |
const polyMesh& mesh_; | |
const potential& pot_; | |
const reducedUnits& redUnits_; | |
List<DynamicList<polyMolecule*> > cellOccupancy_; | |
// InteractionLists<polyMolecule> il_; | |
List<polyMolecule::constantProperties> constPropList_; | |
//- measurement fields | |
polyFieldProperties fields_; | |
//- boundaries | |
polyBoundaries boundaries_; | |
//- controllers | |
polyControllers controllers_; | |
//- polyMolecule tracking | |
polyFaceTracker trackingInfo_; | |
trackingNumber moleculeTracking_; | |
cyclicBoundaries cyclics_; | |
cellInteractions<polyMolecule> iL_; | |
//- interaction particle list | |
List<DynamicList<polyMolecule*> > ipl_; | |
Random rndGen_; | |
int numThreads_; | |
// Private Member Functions | |
void buildConstProps(); | |
void setSiteSizesAndPositions(); | |
//- Determine which molecules are in which cells | |
void calculatePairForces(); | |
// void buildCellOccupancy(); | |
// void calculatePairForce(); | |
// void calculateTetherForce(); | |
// void calculateExternalForce(); | |
void removeHighEnergyOverlaps(); | |
void setTrackingNumbers(); | |
void checkMoleculesInMesh(); | |
void setMoleculesForDirectInteraction(); | |
void computePairForces(); | |
// void computePairForces2(); | |
void accelerationUpdate(); | |
void velocityUpdate(const scalar& trackTime); | |
void updateAfterMove(const scalar& trackTime); | |
//- Disallow default bitwise copy construct | |
polyMoleculeCloud(const polyMoleculeCloud&); | |
//- Disallow default bitwise assignment | |
void operator=(const polyMoleculeCloud&); | |
inline int getNumThreads() const; | |
public: | |
// Static data members | |
// static scalar kb; | |
// | |
// static scalar elementaryCharge; | |
// | |
// static scalar vacuumPermittivity; | |
// Constructors | |
//- Construct for mdFoam | |
polyMoleculeCloud | |
( | |
Time& t, | |
const polyMesh& mesh, | |
const potential& pot, | |
const reducedUnits& rU | |
); | |
//- General constructor | |
polyMoleculeCloud | |
( | |
Time& t, | |
const polyMesh& mesh, | |
const potential& pot, | |
const reducedUnits& rU, | |
const word& option, | |
const bool& clearFields | |
); | |
// Static constructors | |
static autoPtr<polyMoleculeCloud> New | |
( | |
Time& t, | |
const polyMesh& mesh, | |
const potential& pot, | |
const reducedUnits& rU | |
); | |
static autoPtr<polyMoleculeCloud> New | |
( | |
Time& t, | |
const polyMesh& mesh, | |
const potential& pot, | |
const reducedUnits& rU, | |
const word& option, | |
const bool& clearFields | |
); | |
// Member Functions | |
void createMolecule | |
( | |
const vector& position, | |
const label cell, | |
const label tetFace, | |
const label tetPt, | |
const tensor& Q, | |
const vector& v, | |
const vector& a, | |
const vector& pi, | |
const vector& tau, | |
const vector& specialPosition, | |
const label special, | |
const label id, | |
const scalar& fraction, | |
const label trackingNumber | |
); | |
//- Evolve the molecules (move, calculate forces, control state etc) | |
void preliminaries(); | |
void initialHalfVelocity(); | |
void move(); | |
void controlBeforeForces(); | |
void updateAcceleration(); | |
void controlAfterForces(); | |
void finalHalfVelocity(); | |
void postPreliminaries(); | |
void evolve(); | |
void evolveBeforeForces(); | |
void evolveAfterForces(); | |
void clearLagrangianFields(); | |
void calculateForce(); | |
// void calculateForce(); | |
// void calculateForceOF(); | |
// void calculateForceNew(); | |
// void calculateForceIII(); | |
void prepareInteractions(); | |
void buildCellOccupancy(); | |
void rebuildCellOccupancy(); | |
inline void evaluatePair | |
( | |
polyMolecule* molI, | |
polyMolecule* molJ | |
); | |
inline bool evaluatePotentialLimit | |
( | |
polyMolecule* molI, | |
polyMolecule* molJ, | |
const scalar& potentialEnergyLimit | |
) const; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment