1 new commit in enzo-dev:
https://bitbucket.org/enzo/enzo-dev/commits/bc76c0b9ebf0/
Changeset: bc76c0b9ebf0
Branch: week-of-code
User: gbryan
Date: 2018-10-16 18:17:58+00:00
Summary: Merged in brittonsmith/enzo-dev (pull request #424)
Add new must-refine particle option
Approved-by: Greg Bryan <
gbr...@astro.columbia.edu>
Approved-by: John Regan <
johnanth...@gmail.com>
Approved-by: Brian O'shea <
os...@msu.edu>
Affected #: 3 files
diff -r 51cf125453f3 -r bc76c0b9ebf0 doc/manual/source/parameters/index.rst
--- a/doc/manual/source/parameters/index.rst
+++ b/doc/manual/source/parameters/index.rst
@@ -904,7 +904,21 @@
constrained by static grids. Instead, refinement around dark matter
particles is allowed down to the level of a particle's generation level.
Refinement beyond this level is allowed around particles within the MUSIC
- ellipsoidal making region.
+ ellipsoidal masking region. Note, dark matter particles corresponding to
+ a generation level N are guaranteed to be refined to at least level N, but
+ may also exist on levels N > 1 if in the vicinity of an N > 1 dark matter
+ particle or a tagged must-refine particle.
+ 4. Similar to setting 3, except dark matter particles corresponding to a
+ generation level N are refined only to level N and no further. If two
+ dark matter particles from different levels occupy the same cell, that
+ cell will be refined to the coarser level. Tagged must-refine particles
+ near coarse dark matter particles will be similarly de-refined. Compared
+ to option 3, this can be used to prevent unnecessary mesh refinement in
+ regions where coarser particles enter into higher resolution regions,
+ slowing down the simulation. Note, with this setting, coarse boundary
+ particles entering into a high resolution region will eventually lead
+ to total derefinement of the region of interest.
+
``MustRefineParticlesRefineToLevel`` (external)
The maximum level on which ``MustRefineParticles`` are required to
diff -r 51cf125453f3 -r bc76c0b9ebf0 src/enzo/FindSubgrids.C
--- a/src/enzo/FindSubgrids.C
+++ b/src/enzo/FindSubgrids.C
@@ -85,7 +85,8 @@
}
/* Set the static (permanent) regions. */
- if (MustRefineParticlesCreateParticles != 3){
+ if (MustRefineParticlesCreateParticles != 3 &&
+ MustRefineParticlesCreateParticles != 4) {
if (CurrentGrid->SetFlaggingFieldStaticRegions(level, NumberOfFlaggedCells)
== FAIL) {
ENZO_FAIL("Error in grid->SetFlaggingFieldStaticRegions.");
diff -r 51cf125453f3 -r bc76c0b9ebf0 src/enzo/Grid_DepositMustRefineParticles.C
--- a/src/enzo/Grid_DepositMustRefineParticles.C
+++ b/src/enzo/Grid_DepositMustRefineParticles.C
@@ -80,25 +80,49 @@
FlaggingField[i] = 0;
float UniformParticleMass = 0.0;
- if (ProblemType == 30 && MustRefineParticlesCreateParticles == 3)
+ if (ProblemType == 30 &&
+ (MustRefineParticlesCreateParticles == 3 ||
+ MustRefineParticlesCreateParticles == 4))
UniformParticleMass = OmegaDarkMatterNow / OmegaMatterNow;
/* Loop over all particles, marking wich ones are must refine
To add rules, modify number of rules here and add to loop below */
- bool *rules;
+ bool *rules, rule0;
const int NumberOfRules = 2;
rules = new bool[NumberOfRules];
+ // Rules to prevent refinement, cancelling out the above rules.
+ bool *antirules;
+ int *AntiFlaggingField;
+ int NumberOfAntiRules = 0;
+ antirules = new bool[NumberOfAntiRules];
+
+ // Add an antirule to unflag over-refined dark matter particles.
+ if (MustRefineParticlesCreateParticles == 4) {
+ NumberOfAntiRules++;
+ }
+
+ if (NumberOfAntiRules > 0) {
+ antirules = new bool[NumberOfAntiRules];
+ AntiFlaggingField = new int[size];
+ for (i = 0; i < size; i++)
+ AntiFlaggingField[i] = 0;
+ }
+
// Flag particles as must refine particles
- int *IsParticleMustRefine;
+ int *IsParticleMustRefine, *IsParticleNotMustRefine;
IsParticleMustRefine = new int[NumberOfParticles];
+ if (NumberOfAntiRules > 0) {
+ IsParticleNotMustRefine = new int[NumberOfParticles];
+ }
for (i = 0; i < NumberOfParticles; i ++){
IsParticleMustRefine[i] = 1;
// check particle type and uniform mass
- rules[0] = (ParticleType[i] == PARTICLE_TYPE_MUST_REFINE ||
+ rule0 = (ParticleType[i] == PARTICLE_TYPE_MUST_REFINE ||
ParticleType[i] == PARTICLE_TYPE_MBH) ||
(ParticleMass[i] < UniformParticleMass);
+ rules[0] = rule0;
// check particle mass greater than minimum mass
rules[1] = (ParticleMass[i] > MustRefineParticlesMinimumMass);
@@ -110,6 +134,17 @@
// set flag for this particle
for (int j = 0; j < NumberOfRules; j++)
IsParticleMustRefine[i] *= rules[j];
+
+ // anti-rules
+ if (NumberOfAntiRules > 0) {
+ IsParticleNotMustRefine[i] = 1;
+ // check for over-refined dark matter particles
+ antirules[0] = !rule0;
+ }
+
+ // set antiflag for this particle
+ for (int j = 0; j < NumberOfAntiRules; j++)
+ IsParticleNotMustRefine[i] *= antirules[j];
}
PFORTRAN_NAME(cic_flag)(IsParticleMustRefine,
@@ -118,6 +153,18 @@
LeftEdge, GridDimension, GridDimension+1, GridDimension+2,
&CellSize, &ParticleBufferSize);
+ if (NumberOfAntiRules > 0) {
+ PFORTRAN_NAME(cic_flag)(IsParticleNotMustRefine,
+ ParticlePosition[0], ParticlePosition[1], ParticlePosition[2],
+ &GridRank, &NumberOfParticles, AntiFlaggingField,
+ LeftEdge, GridDimension, GridDimension+1, GridDimension+2,
+ &CellSize, &ParticleBufferSize);
+
+ for (i = 0;i < size;i++) {
+ FlaggingField[i] *= !(AntiFlaggingField[i]);
+ }
+ }
+
/* Increase particle mass flagging field for definite refinement */
float MustRefineMass =
@@ -131,7 +178,9 @@
particles, and don't use the particle mass field. */
int NumberOfFlaggedCells = 0;
- if (!(ProblemType == 30 && MustRefineParticlesCreateParticles == 3 &&
+ if (!(ProblemType == 30 &&
+ (MustRefineParticlesCreateParticles == 3 ||
+ MustRefineParticlesCreateParticles == 4) &&
level == MustRefineParticlesRefineToLevel)) {
for (i = 0; i < size; i++)
if (FlaggingField[i]) {
@@ -160,6 +209,12 @@
delete [] IsParticleMustRefine;
delete [] rules;
+ if (NumberOfAntiRules > 0) {
+ delete [] AntiFlaggingField;
+ delete [] IsParticleNotMustRefine;
+ delete [] antirules;
+ }
+
return NumberOfFlaggedCells;
}
Repository URL:
https://bitbucket.org/enzo/enzo-dev/
--
This is a commit notification from
bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.