Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shearing patch #143

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
574bb95
undid stylistic changes, adding shear
brianxchen Jan 29, 2021
d4013d7
Working shear
brianxchen Feb 5, 2021
4069853
Actual working shear update
brianxchen Feb 5, 2021
0e820cd
Split updatePatch into two inlines - now consistent with pkdgrav
brianxchen Feb 11, 2021
17cf950
changes to shearing patch
brianxchen Feb 26, 2021
9c4e2a0
Shearing patch with too wide spread
brianxchen Mar 2, 2021
3990fda
Working shearing patch - tends to ideal line after a long time
brianxchen Mar 5, 2021
ac2ee2c
moved velocity update earlier
brianxchen Mar 19, 2021
ef1786c
added orbital frequency to treepiece calls, shears correctly now
brianxchen May 3, 2021
8f04857
added dorbfreq to remaining drift calls
brianxchen May 3, 2021
ca0601e
attempted removal of dorbfreq in drift calls
brianxchen May 7, 2021
87a2671
fixed shear - moved checkparams before setperiodic
brianxchen May 10, 2021
c539fc3
comments, whitespace changes
brianxchen Jun 13, 2021
7c1a33e
documentation, removed dOrbFreq from TreePiece::kick
brianxchen Jun 18, 2021
9edc5c8
Add --enable-slidingpatch as a configure option.
trquinn Jun 14, 2021
4e28320
changed vector components to .x, .y etc, added sliding patch ifdef to…
brianxchen Aug 9, 2021
5b4a943
typo fixes
brianxchen Aug 9, 2021
f02c59d
ExternalGravity::applyPotential(): correct Hill acceleration.
trquinn Jul 1, 2023
d918e47
Log SLIDING_PATCH and NO_HILL compile options.
trquinn Jul 1, 2023
1e6226a
SLIDING_PATCH: add predicted canonical y momentum for gas.
trquinn Jul 1, 2023
f4d76f1
Use configure from older autoconf version.
trquinn Jul 1, 2023
e7fb427
Cleanup TreePiece.drift() call after Shear rebase.
trquinn Jul 1, 2023
6b2a672
TreePiece::drift(): another rebase cleanup.
trquinn Aug 26, 2023
d6ef32e
Cleaned up formating.
trquinn Dec 31, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion GravityParticle.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ class extraSPHData
double _fESNrate; /* SN energy rate */
double _fTimeCoolIsOffUntil;/* time cooling is turned back on */
Vector3D<double> _vPred; /* Predicted velocities for velocity
dependent forces */
dependent forces */
#ifdef SLIDING_PATCH
double _dPyPred; ///< Predicted canonical momentum
#endif
double _uPred; /* Predicted internal energy */
double _divv; /* Diverence of the velocity */
Vector3D<double> _curlv; /* Curl of the velocity */
Expand Down Expand Up @@ -124,6 +127,9 @@ class extraSPHData
inline double& fESNrate() {return _fESNrate;}
inline double& fTimeCoolIsOffUntil() {return _fTimeCoolIsOffUntil;}
inline Vector3D<double>& vPred() {return _vPred;}
#ifdef SLIDING_PATCH
inline double& dPyPred() {return _dPyPred;}
#endif
inline double& uPred() {return _uPred;}
inline double& divv() {return _divv;}
inline Vector3D<double>& curlv() {return _curlv;}
Expand Down Expand Up @@ -186,6 +192,9 @@ class extraSPHData
p | _fESNrate;
p | _fTimeCoolIsOffUntil;
p | _vPred;
#ifdef SLIDING_PATCH
p | _dPyPred;
#endif
p | _uPred;
p | _divv;
p | _curlv;
Expand Down Expand Up @@ -317,6 +326,10 @@ class GravityParticle : public ExternalGravityParticle {
public:
SFC::Key key;
Vector3D<double> velocity;
#ifdef SLIDING_PATCH
double dPy; ///< Canonical momentum used to update y-velocity
#endif
// inline Vector3D<double>& vPred() { return _vPred; }
Vector3D<cosmoType> treeAcceleration;
cosmoType potential;
cosmoType dtGrav; ///< timestep from gravity; N.B., this
Expand Down Expand Up @@ -364,6 +377,9 @@ class GravityParticle : public ExternalGravityParticle {
ExternalGravityParticle::pup(p);
p | key;
p | velocity;
#ifdef SLIDING_PATCH
p | dPy;
#endif
p | treeAcceleration;
p | dtGrav;
p | fDensity;
Expand Down Expand Up @@ -413,6 +429,9 @@ class GravityParticle : public ExternalGravityParticle {
inline double& fESNrate() {IMAGAS; return (((extraSPHData*)extraData)->fESNrate());}
inline double& fTimeCoolIsOffUntil() {IMAGAS; return (((extraSPHData*)extraData)->fTimeCoolIsOffUntil());}
inline Vector3D<double>& vPred() { IMAGAS; return (((extraSPHData*)extraData)->vPred());}
#ifdef SLIDING_PATCH
inline double& dPyPred() { IMAGAS; return (((extraSPHData*)extraData)->dPyPred());}
#endif
inline double& uPred() {IMAGAS; return (((extraSPHData*)extraData)->uPred());}
inline double& divv() { IMAGAS; return (((extraSPHData*)extraData)->divv());}
inline Vector3D<double>& curlv() { IMAGAS; return (((extraSPHData*)extraData)->curlv());}
Expand Down
1 change: 1 addition & 0 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ defines := $(strip @HEXADECAPOLE@ @FLAG_GDFORCE@ @FLAG_ARCH@ \
@FLAG_JEANSSOFTONLY@ \
@FLAG_TREE_BUILD@ $(debug_defines) @FLAG_INTERLIST@ \
@FLAG_NSMOOTHINNER@ @FLAG_SPLITGAS@ @FLAG_SIDMINTERACT@ \
@FLAG_SLIDING_PATCH@ \
@FLAG_SUPERBUBBLE@ $(cuda_defines) -DREDUCTION_HELPER)

modules := $(strip -language charm++ -balancer @DEFAULT_LB@ \
Expand Down
9 changes: 5 additions & 4 deletions ParallelGravity.ci
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ mainmodule ParallelGravity {
entry void resetObjectLoad(const CkCallback& cb);
entry void setPeriodic(int nReplicas, Vector3D<cosmoType> fPeriod, int bEwald,
double fEwCut, double fEwhCut, int bPeriod,
int bComove, double dRhoFac);
int bComove, double dRhoFac, double dOrbFreq);
entry [notrace] void EwaldInit();
entry [notrace] void initCoolingData(const CkCallback& cb);
entry void calculateEwald(dummyMsg *m);
Expand Down Expand Up @@ -396,7 +396,8 @@ mainmodule ParallelGravity {
entry void assignDomain(const CkCallback &cb);
entry void drift(double dDelta, int bNeedVPred, int bGasIsoThermal,
double dvDelta, double duDelta, int nGrowMass,
bool buildTree, double dMaxEnergy, const CkCallback& cb);
bool buildTree, double dMaxEnergy,
double dTime, const CkCallback& cb);
entry void starCenterOfMass(const CkCallback& cb);
entry void calcEnergy(const CkCallback& cb);
entry void colNParts(const CkCallback &cb);
Expand Down Expand Up @@ -440,9 +441,9 @@ mainmodule ParallelGravity {
entry void liveVizDumpFrameInit(liveVizRequestMsg * msg);
entry void setProjections(int bOn);
#ifdef PUSH_GRAVITY
entry void buildTree(int bucketSize, const CkCallback& cb, bool merge);
entry void buildTree(int bucketSize, double dTime, const CkCallback& cb, bool merge);
#else
entry void buildTree(int bucketSize, const CkCallback& cb);
entry void buildTree(int bucketSize, double dTime, const CkCallback& cb);
#endif

entry void startOctTreeBuild(CkReductionMsg* m);
Expand Down
36 changes: 21 additions & 15 deletions ParallelGravity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1695,9 +1695,9 @@ void Main::buildTree(int iPhase)
CkPrintf("Building trees ... ");
double startTime = CkWallTimer();
#ifdef PUSH_GRAVITY
treeProxy.buildTree(bucketSize, CkCallbackResumeThread(),!bDoPush);
treeProxy.buildTree(bucketSize, dTime, CkCallbackResumeThread(),!bDoPush);
#else
treeProxy.buildTree(bucketSize, CkCallbackResumeThread());
treeProxy.buildTree(bucketSize, dTime, CkCallbackResumeThread());
#endif
double tTB = CkWallTimer()-startTime;
timings[iPhase].tTBuild += tTB;
Expand Down Expand Up @@ -1970,7 +1970,7 @@ void Main::advanceBigStep(int iStep) {
bool bBuildTree = (iSub + 1 == driftSteps);
treeProxy.drift(dDriftFac, param.bDoGas, param.bGasIsothermal,
dKickFac, dTimeSub, nGrowMassDrift, bBuildTree,
param.dMaxEnergy,
param.dMaxEnergy, dTime,
CkCallbackResumeThread());
double tDrift = CkWallTimer() - startTime;
timings[activeRung].tDrift += tDrift;
Expand Down Expand Up @@ -2160,10 +2160,13 @@ void Main::advanceBigStep(int iStep) {
void Main::setupICs() {
double startTime;

param.externalGravity.CheckParams(prm, param);

treeProxy.setPeriodic(param.nReplicas, param.vPeriod, param.bEwald,
param.dEwCut, param.dEwhCut, param.bPeriodic,
param.csm->bComove,
0.5*param.csm->dHubble0*param.csm->dHubble0*param.csm->dOmega0);
0.5*param.csm->dHubble0*param.csm->dHubble0*param.csm->dOmega0,
param.externalGravity.dOrbFreq);

/******** Particles Loading ********/
CkPrintf("Loading particles ...");
Expand Down Expand Up @@ -2300,8 +2303,6 @@ void Main::setupICs() {
if(param.iStartStep) restartNSIDM();
}

param.externalGravity.CheckParams(prm, param);

string achLogFileName = string(param.achOutName) + ".log";
ofstream ofsLog;
if(bIsRestarting)
Expand Down Expand Up @@ -2433,6 +2434,12 @@ void Main::setupICs() {
#endif
#ifdef DAMPING
ofsLog << " DAMPING";
#endif
#ifdef SLIDING_PATCH
ofsLog << " SLIDING_PATCH";
#endif
#ifdef NO_HILL
ofsLog << " NO_HILL";
#endif
ofsLog << endl;
ofsLog << "# Key sizes: " << sizeof(KeyType) << " bytes particle "
Expand Down Expand Up @@ -2496,7 +2503,7 @@ void Main::setupICs() {

// for periodic, puts all particles within the boundary
// Also assigns keys and sorts.
treeProxy.drift(0.0, 0, 0, 0.0, 0.0, 0, true, param.dMaxEnergy,
treeProxy.drift(0.0, 0, 0, 0.0, 0.0, 0, true, param.dMaxEnergy, dTime,
CkCallbackResumeThread());

initialForces();
Expand Down Expand Up @@ -2634,7 +2641,7 @@ Main::restart(CkCheckpointStatusMsg *msg)
} else {
CkPrintf("Not Using CkLoop %d\n", param.bUseCkLoopPar);
}
treeProxy.drift(0.0, 0, 0, 0.0, 0.0, 0, true, param.dMaxEnergy,
treeProxy.drift(0.0, 0, 0, 0.0, 0.0, 0, true, param.dMaxEnergy, dTime,
CkCallbackResumeThread());
if(param.bGasCooling || param.bStarForm)
initCooling();
Expand Down Expand Up @@ -2849,7 +2856,7 @@ Main::doSimulation()
}
// The following drift is called because it deletes the tree
// so it won't be saved on disk.
treeProxy.drift(0.0, 0, 0, 0.0, 0.0, 0, false, param.dMaxEnergy,
treeProxy.drift(0.0, 0, 0, 0.0, 0.0, 0, false, param.dMaxEnergy, dTime,
CkCallbackResumeThread());
treeProxy[0].flushStarLog(CkCallbackResumeThread());
param.iStartStep = iStep; // update so that restart continues on
Expand Down Expand Up @@ -3039,7 +3046,7 @@ Main::doSimulation()
if(param.bDoGas && param.bDoDensity) {
// The following call is to get the particles in key order
// before the sort.
treeProxy.drift(0.0, 0, 0, 0.0, 0.0, 0, true, param.dMaxEnergy,
treeProxy.drift(0.0, 0, 0, 0.0, 0.0, 0, true, param.dMaxEnergy, 0,
CkCallbackResumeThread());
domainDecomp(0);
buildTree(0);
Expand Down Expand Up @@ -3613,8 +3620,8 @@ void Main::writeOutput(int iStep)
if(param.nSteps != 0 && param.bDoDensity) {
// The following call is to get the particles in key order
// before the sort.
treeProxy.drift(0.0, 0, 0, 0.0, 0.0, 0, true, param.dMaxEnergy,
CkCallbackResumeThread());
treeProxy.drift(0.0, 0, 0, 0.0, 0.0, 0, true, param.dMaxEnergy, 0,
CkCallbackResumeThread());
domainDecomp(0);
buildTree(0);

Expand Down Expand Up @@ -3658,7 +3665,7 @@ void Main::writeOutput(int iStep)
startTime = CkWallTimer();
// The following call is to get the particles in key order
// before the sort.
treeProxy.drift(0.0, 0, 0, 0.0, 0.0, 0, true, param.dMaxEnergy,
treeProxy.drift(0.0, 0, 0, 0.0, 0.0, 0, true, param.dMaxEnergy, 0,
CkCallbackResumeThread());
domainDecomp(0);
buildTree(0);
Expand All @@ -3681,11 +3688,10 @@ void Main::writeOutput(int iStep)
// processors for continuing the simulation.
// The following call is to get the particles in key order
// before the sort.
treeProxy.drift(0.0, 0, 0, 0.0, 0.0, 0, true, param.dMaxEnergy,
treeProxy.drift(0.0, 0, 0, 0.0, 0.0, 0, true, param.dMaxEnergy, dTime,
CkCallbackResumeThread());
domainDecomp(0);
}

if(param.iBinaryOut == 6)
writeNCXML(achFile);
}
Expand Down
43 changes: 31 additions & 12 deletions ParallelGravity.h
Original file line number Diff line number Diff line change
Expand Up @@ -1203,6 +1203,7 @@ class TreePiece : public CBase_TreePiece {
/// Background density of the Universe
double dRhoFac;
Vector3D<cosmoType> fPeriod;
double dOrbFreq; ///< Orbital frequency of patch
int nReplicas;
int bEwald; /* Perform Ewald */
double fEwCut;
Expand Down Expand Up @@ -1330,10 +1331,9 @@ class TreePiece : public CBase_TreePiece {
// called when a chunk has been used completely (chunkRemaining[chunk] == 0)
void finishedChunk(int chunk);

///Array of comparison function pointers
/// Array of comparison function pointers for ORB tree build
bool (*compFuncPtr[3])(GravityParticle,GravityParticle);
double tmpTime;
double totalTime;
double dTimeTree; ///< Simulation time tree is built
public:

#ifdef SPCUDA
Expand Down Expand Up @@ -1468,8 +1468,7 @@ class TreePiece : public CBase_TreePiece {
#endif
#endif

tmpTime=0.0;
totalTime=0.0;
dTimeTree = 0.0;
// temporarely set to -1, it will updated after the tree is built
numChunks=-1;
prefetchRoots = NULL;
Expand Down Expand Up @@ -1581,7 +1580,7 @@ class TreePiece : public CBase_TreePiece {

void setPeriodic(int nReplicas, Vector3D<cosmoType> fPeriod, int bEwald,
double fEwCut, double fEwhCut, int bPeriod,
int bComove, double dRhoFac);
int bComove, double dRhoFac, double dOrbFreq);
void BucketEwald(GenericTreeNode *req, int nReps,double fEwCut);
void EwaldInit();
void calculateEwald(dummyMsg *m);
Expand Down Expand Up @@ -1706,7 +1705,7 @@ class TreePiece : public CBase_TreePiece {
double dMultiPhaseMaxTime, double dMultiPhaseMinTemp, double dEvapCoeff, const CkCallback& cb);
void drift(double dDelta, int bNeedVPred, int bGasIsothermal, double dvDelta,
double duDelta, int nGrowMass, bool buildTree, double dMaxEnergy,
const CkCallback& cb);
double dTime, const CkCallback& cb);
void initAccel(int iKickRung, const CkCallback& cb);
#ifdef COOLING_MOLECULARH
void distribLymanWerner(const CkCallback& cb);
Expand Down Expand Up @@ -1825,10 +1824,13 @@ class TreePiece : public CBase_TreePiece {
void setProjections(int bOn);

/// \brief Charm entry point to build the tree (called by Main).
/// \param bucketSize Maximum particles per bucket
/// \param dTime Simulation time tree is built
/// \param cb Callback after tree is built
#ifdef PUSH_GRAVITY
void buildTree(int bucketSize, const CkCallback& cb, bool merge);
void buildTree(int bucketSize, double dTime, const CkCallback& cb, bool merge);
#else
void buildTree(int bucketSize, const CkCallback& cb);
void buildTree(int bucketSize, double dTime, const CkCallback& cb);
#endif

/// \brief Real tree build, independent of other TreePieces.
Expand Down Expand Up @@ -2005,15 +2007,32 @@ class TreePiece : public CBase_TreePiece {
// jetley
// need this in TreeWalk
GenericTreeNode *getRoot() {return root;}
// need this in Compute
/// @brief adjust y (azimuthal) position if we are crossing an
/// x (radial) boundary
/// @return change in y position
inline double SHEAR(int ix, ///< Interior or exterior?
double t, ///< Current simulation time
Vector3D<cosmoType> fPeriod, ///< patch size
double dOrbFreq) ///< Orbital frequency
{
#ifdef SLIDING_PATCH
return
(ix < 0) ? fmod(0.5 * fPeriod.y - 1.5 * ix * dOrbFreq * fPeriod.x * t, fPeriod.y) - 0.5 * fPeriod.y :
(ix > 0) ? 0.5 * fPeriod.y - fmod(0.5 * fPeriod.y + 1.5 * ix * dOrbFreq * fPeriod.x * t, fPeriod.y) : 0.0;
#else
return 0.0;
#endif
}

inline Vector3D<cosmoType> decodeOffset(int reqID) {
int offsetcode = reqID >> 22;
int x = (offsetcode & 0x7) - 3;
int y = ((offsetcode >> 3) & 0x7) - 3;
int z = ((offsetcode >> 6) & 0x7) - 3;

Vector3D<cosmoType> offset(x*fPeriod.x, y*fPeriod.y, z*fPeriod.z);

Vector3D<cosmoType> offset(x*fPeriod.x,
y*fPeriod.y + SHEAR(x, dTimeTree, fPeriod.y, dOrbFreq),
z*fPeriod.z);
return offset;
}

Expand Down
Loading
Loading