Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
18 changes: 10 additions & 8 deletions include/aspect/particle/property/cpo_bingham_average.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ namespace aspect
void
initialize () override;

void
update () override;

/**
* Initialization function. This function is called once at the
* creation of every particle for every property to initialize its
Expand Down Expand Up @@ -159,12 +162,6 @@ namespace aspect
void
parse_parameters (ParameterHandler &prm) override;

void
save (std::map<std::string, std::string> &status_strings) const override;

void
load (const std::map<std::string, std::string> &status_strings) override;

private:
/**
* stores the position of the cpo data in the particle property vector
Expand All @@ -178,8 +175,13 @@ namespace aspect
std::unique_ptr<const Particle::Property::CrystalPreferredOrientation<dim>> cpo_particle_property;

/**
* Random number generator. For reproducibility of tests it is
* initialized in the constructor with a constant plus the MPI rank.
* Random number generator.
*
* This variable is not considered part of the state of the particle
* manager and is consequently not serialized. It is re-initialized in the
* initialize() and update() functions at the beginning of each time step, and so
* has a deterministic state at the beginning of each time step. It
* does not need to be restored from a checkpoint.
*/
mutable std::mt19937 random_number_generator;

Expand Down
40 changes: 14 additions & 26 deletions source/particle/property/cpo_bingham_average.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,20 @@ namespace aspect



template <int dim>
void
CpoBinghamAverage<dim>::update ()
{
// Set the random number generator seed to a different value for each MPI process and
// timestep to ensure that the random numbers are different for each process and timestep,
// but at the same time reproducible for each process and timestep. With this trick,
// we don't have to serialize the random number generator.
const unsigned int my_rank = Utilities::MPI::this_mpi_process(MPI_COMM_WORLD);
this->random_number_generator.seed(random_number_seed + my_rank + this->get_timestep_number());
}



template <int dim>
void
CpoBinghamAverage<dim>::initialize_one_particle_property(const Point<dim> &,
Expand Down Expand Up @@ -407,32 +421,6 @@ namespace aspect
}
prm.leave_subsection ();
}



template <int dim>
void
CpoBinghamAverage<dim>::save (std::map<std::string, std::string> &status_strings) const
{
std::ostringstream os;
os << random_number_generator;
status_strings["CpoBinghamAverage"] = os.str();
}



template <int dim>
void
CpoBinghamAverage<dim>::load (const std::map<std::string, std::string> &status_strings)
{
const auto saved_state = status_strings.find("CpoBinghamAverage");
if (saved_state != status_strings.end())
{
std::istringstream is (saved_state->second);
is >> random_number_generator;
AssertThrow(!is.fail(), ExcMessage("Could not restore the CPO Bingham average random number generator."));
}
}
}
}
}
Expand Down
16 changes: 8 additions & 8 deletions tests/cpo_induced_anisotropic_viscosity/screen-output
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Number of degrees of freedom: 494 (81+8+27+27+27+27+27+27+27+27+27+27+27+27+27+2

Postprocessing:
RMS, max velocity: 0.289 m/s, 0.5 m/s
Compositions min/max/mass: 1.788e+24/1.788e+24/1.788e+24 // 5.276/5.276/5.276 // 0.5203/0.5203/0.5203 // 0.3479/0.3479/0.3479 // 0.1318/0.1318/0.1318 // 1.736/1.736/1.736 // 0.5743/0.5743/0.5743 // 0.3808/0.3808/0.3808 // 0.04489/0.04489/0.04489 // 5.435/5.435/5.435 // 0.6079/0.6079/0.6079 // 0.3106/0.3106/0.3106 // 0.08157/0.08157/0.08157 // 0/0/0
Compositions min/max/mass: 1.788e+24/1.788e+24/1.788e+24 // 4.491/4.491/4.491 // 0.5971/0.5971/0.5971 // 0.2605/0.2605/0.2605 // 0.1425/0.1425/0.1425 // 1.425/1.425/1.425 // 0.4539/0.4539/0.4539 // 0.4275/0.4275/0.4275 // 0.1185/0.1185/0.1185 // 0.2624/0.2624/0.2624 // 0.5367/0.5367/0.5367 // 0.3422/0.3422/0.3422 // 0.121/0.121/0.121 // 0/0/0
Writing graphical output: output-cpo_induced_anisotropic_viscosity/solution/solution-00000
Writing particle output: output-cpo_induced_anisotropic_viscosity/particles/particles-00000
Writing particle cpo output: output-cpo_induced_anisotropic_viscosity/particles_cpo/CPO-00000
Expand All @@ -27,7 +27,7 @@ Number of degrees of freedom: 494 (81+8+27+27+27+27+27+27+27+27+27+27+27+27+27+2

Postprocessing:
RMS, max velocity: 0.289 m/s, 0.5 m/s
Compositions min/max/mass: 2.038e+07/2.038e+07/2.038e+07 // 4.654/4.654/4.654 // 0.6551/0.6551/0.6551 // 0.2233/0.2233/0.2233 // 0.1217/0.1217/0.1217 // 2.055/2.055/2.055 // 0.5386/0.5386/0.5386 // 0.4457/0.4457/0.4457 // 0.01567/0.01567/0.01567 // 0.08621/0.08621/0.08621 // 0.4653/0.4653/0.4653 // 0.3568/0.3568/0.3568 // 0.1779/0.1779/0.1779 // 0/0/0
Compositions min/max/mass: 1.85e+07/1.85e+07/1.85e+07 // 4.71/4.71/4.71 // 0.6881/0.6881/0.6881 // 0.2711/0.2711/0.2711 // 0.0408/0.0408/0.0408 // 2.26/2.26/2.26 // 0.6349/0.6349/0.6349 // 0.3225/0.3225/0.3225 // 0.0426/0.0426/0.0426 // 0.3944/0.3944/0.3944 // 0.5547/0.5547/0.5547 // 0.3085/0.3085/0.3085 // 0.1368/0.1368/0.1368 // 0/0/0
Writing graphical output: output-cpo_induced_anisotropic_viscosity/solution/solution-00001
Writing particle output: output-cpo_induced_anisotropic_viscosity/particles/particles-00001
Writing particle cpo output: output-cpo_induced_anisotropic_viscosity/particles_cpo/CPO-00001
Expand All @@ -41,7 +41,7 @@ Number of degrees of freedom: 494 (81+8+27+27+27+27+27+27+27+27+27+27+27+27+27+2

Postprocessing:
RMS, max velocity: 0.289 m/s, 0.5 m/s
Compositions min/max/mass: 1.787e+07/1.787e+07/1.787e+07 // 4.682/4.682/4.682 // 0.687/0.687/0.687 // 0.2543/0.2543/0.2543 // 0.05866/0.05866/0.05866 // 1.956/1.956/1.956 // 0.6427/0.6427/0.6427 // 0.318/0.318/0.318 // 0.03931/0.03931/0.03931 // 0.2642/0.2642/0.2642 // 0.5393/0.5393/0.5393 // 0.2979/0.2979/0.2979 // 0.1628/0.1628/0.1628 // 0/0/0
Compositions min/max/mass: 1.759e+07/1.759e+07/1.759e+07 // 5.713/5.713/5.713 // 0.5306/0.5306/0.5306 // 0.3232/0.3232/0.3232 // 0.1462/0.1462/0.1462 // 2.477/2.477/2.477 // 0.4802/0.4802/0.4802 // 0.451/0.451/0.451 // 0.06885/0.06885/0.06885 // 1.877/1.877/1.877 // 0.5391/0.5391/0.5391 // 0.2814/0.2814/0.2814 // 0.1795/0.1795/0.1795 // 0/0/0
Writing graphical output: output-cpo_induced_anisotropic_viscosity/solution/solution-00002
Writing particle output: output-cpo_induced_anisotropic_viscosity/particles/particles-00002
Writing particle cpo output: output-cpo_induced_anisotropic_viscosity/particles_cpo/CPO-00002
Expand All @@ -55,7 +55,7 @@ Number of degrees of freedom: 494 (81+8+27+27+27+27+27+27+27+27+27+27+27+27+27+2

Postprocessing:
RMS, max velocity: 0.289 m/s, 0.5 m/s
Compositions min/max/mass: 1.79e+07/1.79e+07/1.79e+07 // 4.901/4.901/4.901 // 0.5217/0.5217/0.5217 // 0.3452/0.3452/0.3452 // 0.1331/0.1331/0.1331 // 1.327/1.327/1.327 // 0.507/0.507/0.507 // 0.4874/0.4874/0.4874 // 0.005555/0.005555/0.005555 // 6.167/6.167/6.167 // 0.8138/0.8138/0.8138 // 0.165/0.165/0.165 // 0.02117/0.02117/0.02117 // 0/0/0
Compositions min/max/mass: 1.893e+07/1.893e+07/1.893e+07 // 4.297/4.297/4.297 // 0.7369/0.7369/0.7369 // 0.2051/0.2051/0.2051 // 0.058/0.058/0.058 // 1.66/1.66/1.66 // 0.5205/0.5205/0.5205 // 0.409/0.409/0.409 // 0.07048/0.07048/0.07048 // 0.1543/0.1543/0.1543 // 0.4839/0.4839/0.4839 // 0.3966/0.3966/0.3966 // 0.1195/0.1195/0.1195 // 0/0/0
Writing graphical output: output-cpo_induced_anisotropic_viscosity/solution/solution-00003
Writing particle output: output-cpo_induced_anisotropic_viscosity/particles/particles-00003
Writing particle cpo output: output-cpo_induced_anisotropic_viscosity/particles_cpo/CPO-00003
Expand All @@ -65,11 +65,11 @@ Number of degrees of freedom: 494 (81+8+27+27+27+27+27+27+27+27+27+27+27+27+27+2
Advecting particles... done.
Copying properties into prescribed compositional field scalar_viscosity... done.
Rebuilding Stokes preconditioner...
Solving Stokes system (AMG)... 8+0 iterations.
Solving Stokes system (AMG)... 6+0 iterations.

Postprocessing:
RMS, max velocity: 0.289 m/s, 0.5 m/s
Compositions min/max/mass: 1.984e+07/1.984e+07/1.984e+07 // 5.401/5.401/5.401 // 0.5239/0.5239/0.5239 // 0.3726/0.3726/0.3726 // 0.1035/0.1035/0.1035 // 2.101/2.101/2.101 // 0.5855/0.5855/0.5855 // 0.3469/0.3469/0.3469 // 0.06767/0.06767/0.06767 // 4.669/4.669/4.669 // 0.674/0.674/0.674 // 0.1845/0.1845/0.1845 // 0.1415/0.1415/0.1415 // 0/0/0
Compositions min/max/mass: 1.774e+07/1.774e+07/1.774e+07 // 4.791/4.791/4.791 // 0.6659/0.6659/0.6659 // 0.1822/0.1822/0.1822 // 0.152/0.152/0.152 // 2.34/2.34/2.34 // 0.607/0.607/0.607 // 0.3396/0.3396/0.3396 // 0.05341/0.05341/0.05341 // 0.6204/0.6204/0.6204 // 0.5973/0.5973/0.5973 // 0.2441/0.2441/0.2441 // 0.1585/0.1585/0.1585 // 0/0/0
Writing graphical output: output-cpo_induced_anisotropic_viscosity/solution/solution-00004
Writing particle output: output-cpo_induced_anisotropic_viscosity/particles/particles-00004
Writing particle cpo output: output-cpo_induced_anisotropic_viscosity/particles_cpo/CPO-00004
Expand All @@ -79,11 +79,11 @@ Number of degrees of freedom: 494 (81+8+27+27+27+27+27+27+27+27+27+27+27+27+27+2
Advecting particles... done.
Copying properties into prescribed compositional field scalar_viscosity... done.
Rebuilding Stokes preconditioner...
Solving Stokes system (AMG)... 10+0 iterations.
Solving Stokes system (AMG)... 6+0 iterations.

Postprocessing:
RMS, max velocity: 0.289 m/s, 0.5 m/s
Compositions min/max/mass: 1.923e+07/1.923e+07/1.923e+07 // 4.104/4.104/4.104 // 0.7394/0.7394/0.7394 // 0.1602/0.1602/0.1602 // 0.1004/0.1004/0.1004 // 1.107/1.107/1.107 // 0.5986/0.5986/0.5986 // 0.3103/0.3103/0.3103 // 0.09108/0.09108/0.09108 // 6.233/6.233/6.233 // 0.563/0.563/0.563 // 0.2924/0.2924/0.2924 // 0.1446/0.1446/0.1446 // 0/0/0
Compositions min/max/mass: 1.814e+07/1.814e+07/1.814e+07 // 4.414/4.414/4.414 // 0.7513/0.7513/0.7513 // 0.2082/0.2082/0.2082 // 0.04052/0.04052/0.04052 // 2.036/2.036/2.036 // 0.5575/0.5575/0.5575 // 0.3277/0.3277/0.3277 // 0.1149/0.1149/0.1149 // 0.4004/0.4004/0.4004 // 0.5503/0.5503/0.5503 // 0.3631/0.3631/0.3631 // 0.08657/0.08657/0.08657 // 0/0/0
Writing graphical output: output-cpo_induced_anisotropic_viscosity/solution/solution-00005
Writing particle output: output-cpo_induced_anisotropic_viscosity/particles/particles-00005
Writing particle cpo output: output-cpo_induced_anisotropic_viscosity/particles_cpo/CPO-00005
Expand Down
Loading
Loading