Skip to content

Commit

Permalink
Merge pull request #6247 from gassmoeller/use_simulator_access_for_GMG
Browse files Browse the repository at this point in the history
SimulatorAccess for StokesMatrixFree
  • Loading branch information
tjhei authored Mar 4, 2025
2 parents be825e7 + 68235f4 commit c2a18ca
Show file tree
Hide file tree
Showing 3 changed files with 230 additions and 220 deletions.
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

0 comments on commit c2a18ca

Please sign in to comment.