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

SimulatorAccess for StokesMatrixFree #6247

Merged
merged 1 commit into from
Mar 4, 2025
Merged
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
34 changes: 18 additions & 16 deletions include/aspect/stokes_matrix_free.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@
#define _aspect_stokes_matrix_free_h

#include <aspect/global.h>
#include <aspect/plugins.h>

#include <aspect/simulator.h>
#include <aspect/simulator_access.h>

#include <deal.II/matrix_free/matrix_free.h>
#include <deal.II/matrix_free/operators.h>
Expand Down Expand Up @@ -400,14 +402,9 @@ namespace aspect
* actual implementation is found inside StokesMatrixFreeHandlerImplementation below.
*/
template <int dim>
class StokesMatrixFreeHandler
class StokesMatrixFreeHandler: public SimulatorAccess<dim>, public Plugins::InterfaceBase
{
public:
/**
* virtual Destructor.
*/
virtual ~StokesMatrixFreeHandler() = default;

/**
* Solves the Stokes linear system using the matrix-free
* solver.
Expand Down Expand Up @@ -442,7 +439,7 @@ namespace aspect
virtual void build_preconditioner()=0;

/**
* Declare parameters.
* Declare parameters necessary for this solver.
*/
static
void declare_parameters (ParameterHandler &prm);
Expand Down Expand Up @@ -518,18 +515,23 @@ namespace aspect
{
public:
/**
* Initialize this class, allowing it to read in
* relevant parameters as well as giving it a reference to the
* Constructor. Give it a reference to the
* Simulator that owns it, since it needs to make fairly extensive
* changes to the internals of the simulator.
*/
StokesMatrixFreeHandlerImplementation(Simulator<dim> &, ParameterHandler &prm);
StokesMatrixFreeHandlerImplementation(Simulator<dim> &simulator,
const Parameters<dim> &parameters);

/**
* Destructor.
*/
~StokesMatrixFreeHandlerImplementation() override = default;

/**
* Initialize the matrix-free solver.
*/
void initialize() override;

/**
* Solves the Stokes linear system using the matrix-free
* solver.
Expand Down Expand Up @@ -563,11 +565,16 @@ namespace aspect
void build_preconditioner() override;

/**
* Declare parameters. (No actual parameters at the moment).
* Declare parameters.
*/
static
void declare_parameters (ParameterHandler &prm);

/**
* Parse parameters.
*/
void parse_parameters (ParameterHandler &prm) override;

/**
* Return a reference to the DoFHandler that is used for velocity in
* the block GMG solver.
Expand Down Expand Up @@ -625,11 +632,6 @@ namespace aspect
std::size_t get_cell_data_memory_consumption() const override;

private:
/**
* Parse parameters.
*/
void parse_parameters (ParameterHandler &prm);

/**
* Evaluate the MaterialModel to query information like the viscosity and
* project this viscosity to the multigrid hierarchy. Also queries
Expand Down
7 changes: 5 additions & 2 deletions source/simulator/core.cc
Original file line number Diff line number Diff line change
Expand Up @@ -432,15 +432,18 @@ namespace aspect
switch (parameters.stokes_velocity_degree)
{
case 2:
stokes_matrix_free = std::make_unique<StokesMatrixFreeHandlerImplementation<dim,2>>(*this, prm);
stokes_matrix_free = std::make_unique<StokesMatrixFreeHandlerImplementation<dim,2>>(*this, parameters);
break;
case 3:
stokes_matrix_free = std::make_unique<StokesMatrixFreeHandlerImplementation<dim,3>>(*this, prm);
stokes_matrix_free = std::make_unique<StokesMatrixFreeHandlerImplementation<dim,3>>(*this, parameters);
break;
default:
AssertThrow(false, ExcMessage("The finite element degree for the Stokes system you selected is not supported yet."));
}

stokes_matrix_free->initialize_simulator(*this);
stokes_matrix_free->parse_parameters(prm);
stokes_matrix_free->initialize();
}

postprocess_manager.initialize_simulator (*this);
Expand Down
Loading