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
3 changes: 3 additions & 0 deletions doc/modules/changes/20260711_lhy11009
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Changed: add support for updating the InitialComposition particle property using the prescribed solution plugin.
<br>
(Haoyuan Li, 2026/07/11)
7 changes: 7 additions & 0 deletions include/aspect/particle/property/initial_composition.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ namespace aspect
initialize_one_particle_property (const Point<dim> &position,
std::vector<double> &particle_properties) const override;

/**
* @copydoc aspect::Particle::Property::Interface::update_particle_properties()
*/
void
update_particle_properties (const ParticleUpdateInputs<dim> &inputs,
typename ParticleHandler<dim>::particle_iterator_range &particles) const override;

/**
* Returns an enum, which determines how this particle property is
* initialized for particles that are created later than the initial
Expand Down
38 changes: 38 additions & 0 deletions source/particle/property/initial_composition.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include <aspect/particle/property/initial_composition.h>
#include <aspect/initial_composition/interface.h>
#include <aspect/prescribed_solution/interface.h>

namespace aspect
{
Expand Down Expand Up @@ -80,6 +81,43 @@ namespace aspect

return property_information;
}

template <int dim>
void
InitialComposition<dim>::update_particle_properties(const ParticleUpdateInputs<dim> &/*inputs*/,
typename ParticleHandler<dim>::particle_iterator_range &particles) const
{
const aspect::PrescribedSolution::Manager<dim> &prescribed_solution_manager = this->get_prescribed_solution();
const auto &plugin_objects = prescribed_solution_manager.get_active_plugins();


std::vector<Point<dim>> evaluation_points(1);
std::vector<unsigned int> component_indices(1);
std::vector<bool> component_is_constrained(1);
std::vector<double> constrained_component_value(1);

for (auto &particle : particles)
{
evaluation_points[0] = particle.get_location();

for (unsigned int j = 0; j < this->n_compositional_fields(); ++j)
{
component_indices[0] = this->introspection().component_indices.compositional_fields[j];
component_is_constrained[0] = false;
constrained_component_value[0] = 0.0;

for (const auto &plugin : plugin_objects)
{
typename DoFHandler<dim>::active_cell_iterator cell;
plugin->constrain_solution(cell, evaluation_points, component_indices, component_is_constrained, constrained_component_value);
}

if (component_is_constrained[0])
particle.get_properties()[this->data_position+j] = constrained_component_value[0];
}
}
}

}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#########################################################
# This is modified from the composition_passive.prm
# parameter file by prescribing the compositional solution
# from initial compositional fields and using the particle
# method

include $ASPECT_SOURCE_DIR/cookbooks/composition_passive/composition_passive.prm

# Modify the original cookbook to end earlier
set Start time = 0
set End time = 0.1
set Use years instead of seconds = false

# Modify the original cookbook to have coarser meshes
subsection Mesh refinement
set Initial adaptive refinement = 0
set Initial global refinement = 3
set Time steps between mesh refinement = 0
end

# Modify the compositional fields to use particles
subsection Compositional fields
set Number of fields = 2
set Compositional field methods = particles, particles
set Mapped particle properties = C_1: initial C_1, C_2: initial C_2
end

# Include the particles
subsection Particles
set Minimum particles per cell = 25
set Maximum particles per cell = 100
set Load balancing strategy = remove and add particles
set List of particle properties = initial composition, position
set Interpolation scheme = bilinear least squares
set Update ghost particles = true
set Particle generator name = reference cell
subsection Generator
subsection Reference cell
set Number of particles per cell per direction = 7
end
end
end

# The next section prescribes the composition inside the domain
# using a spatially varying function. An indicator function selects
# the region where the composition is constrained.
subsection Prescribed solution
Comment thread
lhy11009 marked this conversation as resolved.
set List of model names = initial composition
subsection Initial composition
subsection Indicator function
set Variable names = x, y
set Function expression = (x<1) ? 1:0
end
end
end

subsection Postprocess
set List of postprocessors = visualization

subsection Visualization
set Interpolate output = false
set Time between graphical output = 0.1
set Output format = gnuplot
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

Number of active cells: 64 (on 4 levels)
Number of degrees of freedom: 1,526 (578+81+289+289+289)

*** Timestep 0: t=0 seconds, dt=0 seconds
Solving temperature system... 0 iterations.
Advecting particles... done.
Solving Stokes system (GMG)... 11+0 iterations.

Postprocessing:
Writing graphical output: output-prescribed_solution_composition_initial_condition_particles/solution/solution-00000

*** Timestep 1: t=0.0625 seconds, dt=0.0625 seconds
Solving temperature system... 10 iterations.
Advecting particles... done.
Solving Stokes system (GMG)... 7+0 iterations.

Postprocessing:

*** Timestep 2: t=0.1 seconds, dt=0.0375 seconds
Solving temperature system... 10 iterations.
Advecting particles... done.
Solving Stokes system (GMG)... 12+0 iterations.

Postprocessing:
Writing graphical output: output-prescribed_solution_composition_initial_condition_particles/solution/solution-00001

Termination requested by criterion: end time



Loading
Loading