Peano
Loading...
Searching...
No Matches
solvers.api.CollocatedDLinearDiscretisationWithPointJacobi.CollocatedDLinearDiscretisationWithPointJacobi Class Reference

Matrix-free Collocated Solver for d-linear shape functions. More...

Inheritance diagram for solvers.api.CollocatedDLinearDiscretisationWithPointJacobi.CollocatedDLinearDiscretisationWithPointJacobi:
Collaboration diagram for solvers.api.CollocatedDLinearDiscretisationWithPointJacobi.CollocatedDLinearDiscretisationWithPointJacobi:

Public Member Functions

 __init__ (self, name, unknowns_per_vertex, dimensions, min_h, max_h, local_assembly_matrix, local_assembly_matrix_scaling, mass_matrix, mass_matrix_scaling, solver_tolerance, smoother_relaxation=0.6, custom_init_actionset=None, custom_plot_actionset=None, custom_init_vertex="", custom_boundary_conditions="", enable_plotting=True, plot_predicate="true")
 Collocated low-order (d-linear) Finite Elements.
 
 add_to_Peano4_datamodel (self, datamodel, verbose)
 
 add_use_statements (self, observer)
 This routine should still be called even if overwritten in child class.
 
 add_to_plot (self, observer)
 Tell the project's observer how to plot the data.
 
 add_to_create_grid (self, observer)
 
 add_to_init_solution (self, observer)
 Solution initialisation.
 
 add_to_solve (self, observer)
 
 add_implementation_files_to_project (self, namespace, output, subdirectory="", abstract_overwrite=True)
 The solver creates two classes: An abstract base class and its implementations.
 
 get_vertex_merge_method (self)
 
- Public Member Functions inherited from solvers.api.Solver.Solver
 typename (self)
 
 instance_name (self)
 Return the name of the object that will be created for this solver.
 
 create_readme_descriptor (self)
 
 add_to_abstract_solver (self, header, implementation)
 
 add_to_vertex_data (self, name, size)
 Add in extra attributes on the fly.
 
 add_to_cell_data (self, name, size)
 Add in extra attributes on the fly.
 
 add_to_face_data (self, name, size)
 Add in extra attributes on the fly.
 
 name (self)
 
 __str__ (self)
 

Data Fields

 max_h
 
 min_h
 
- Data Fields inherited from solvers.api.Solver.Solver
 min_h
 
 max_h
 

Protected Attributes

 _unknowns_per_vertex_node
 
 _local_assembly_matrix
 
 _local_assembly_matrix_scaling
 
 _mass_matrix
 
 _mass_matrix_scaling
 
 _solver_tolerance
 
 _basic_descend_order
 
 _smoother_relaxation
 
 _custom_init_actionset
 
 _custom_plot_actionset
 
 _custom_init_vertex
 
 _custom_boundary_conditions
 
 _enable_plotting
 
 _plot_predicate
 
 _abstract_solver_header_extras
 
 _abstract_solver_implementation_extras
 
- Protected Attributes inherited from solvers.api.Solver.Solver
 _name
 
 _vertex_data
 
 _face_data
 
 _cell_data
 
 _abstract_solver_header_extras
 
 _abstract_solver_implementation_extras
 

Detailed Description

Matrix-free Collocated Solver for d-linear shape functions.

Mathematical and algorithmic descriptions are to follow later. For now, we describe how to use this solver and a little about how it works under the hood.

Each vertex stores a certain number of values, given by the parameter unknowns_per_vertex. In essence, if this parameter is more than one, we are solving multiple different equations simultaneously, or we can equivalently think of our PDE being vector-valued.

The user needs to provide an assembly matrix, and a mass matrix. If our vector-valued PDE has \( K \) components, then each of these matrices should be square, with \( K * 2^D \) rows.

In particular, they should be structured as block diagonals. Let \( A_i \) be square with \( 2^D \) rows. Then the mass/assembly matrices should be structured as follows:

\( diag( A_1, A_2, \dots A_K ) \).

During the actual solver step, we run through each equation one after another, fetching the appropriate mass and assembly matrices for the equation in hand.

At present, it hasn't been decided how to plot the output of multiple equations, since only 1 is supported.

Data held on the vertices

Solution (formerly named Value)

This array holds the actual solution which we later plot. This is updated when we touch a vertex for the last time.

Rhs

This array holds the right-hand side of the equation. We assign this in experiment-specific implementation files.

Diagonal

This array holds the sum of the diagonals of the local assembly matrix. This is set to 0 at the start of every solver step

Residual

This is used to store \( Mb - Ax \), i.e. the RHS multiplied by the matrix, and subtract the solution multiplied by the assembly matrix.

Solver Steps

Initialisation

After the grid is created, we run around the mesh and assign types to the vertices and cells.

Vertices:

  • "Coarse" if the vertex is due to be refined
  • "Interior" if it's not on the boundary
  • "Boundary" if it is on the boundary

Cells:

  • "Coarse" if it's due to be refined
  • Otherwise marked as "Interior"

Solve

There is only one action set in this solver. We do something non-trivial during touchCellFirstTime, touchVertexFirstTime and touchVertexLastTime.

touchVertexFirstTime

We check that the Vertex is not a coarse grid vertex, then we set the residuals and the diagonals to 0.

touchCellFirstTime

All four vertices are in scope here. We create three vectors, each of length \( 2^D \) to hold one value per vertex. For each vertex in the cell (regardless of whether it is on the boundary), we :

  • Update the residual to be \( Mb - Ax \)
  • Increment the diagonal

touchVertexLastTime

We update the solution value (on all vertices) to be equal to the solution at the previous sweep, and we add on \( \omega \times r / d \) where \( r \) and \( d \) stand for the residual and diagonal respectively.

Enforcement of boundary conditions

Todos

We currently overcount the residual on vertices that are shared across boundaries. This isn't an issue at present, since we only check for the max, which is unaffected by this bug. But something to fix at later date.

Definition at line 19 of file CollocatedDLinearDiscretisationWithPointJacobi.py.

Constructor & Destructor Documentation

◆ __init__()

solvers.api.CollocatedDLinearDiscretisationWithPointJacobi.CollocatedDLinearDiscretisationWithPointJacobi.__init__ (   self,
  name,
  unknowns_per_vertex,
  dimensions,
  min_h,
  max_h,
  local_assembly_matrix,
  local_assembly_matrix_scaling,
  mass_matrix,
  mass_matrix_scaling,
  solver_tolerance,
  smoother_relaxation = 0.6,
  custom_init_actionset = None,
  custom_plot_actionset = None,
  custom_init_vertex = "",
  custom_boundary_conditions = "",
  enable_plotting = True,
  plot_predicate = "true" 
)

Member Function Documentation

◆ add_implementation_files_to_project()

solvers.api.CollocatedDLinearDiscretisationWithPointJacobi.CollocatedDLinearDiscretisationWithPointJacobi.add_implementation_files_to_project (   self,
  namespace,
  output,
  subdirectory = "",
  abstract_overwrite = True 
)

The solver creates two classes: An abstract base class and its implementations.

The abstract base class will be overwritten if there is one in the directory. I pipe all the Python constants into this base class, so they are available in the C++ code.

Definition at line 258 of file CollocatedDLinearDiscretisationWithPointJacobi.py.

References peano4.api.output.ActionSet.ActionSet.__class__, peano4.api.output.Jinja2TemplatedHeaderImplementationFilePair.Jinja2TemplatedHeaderImplementationFilePair.__class__, and peano4.api.output.TemplatedHeaderFile.TemplatedHeaderFile.__class__.

◆ add_to_create_grid()

solvers.api.CollocatedDLinearDiscretisationWithPointJacobi.CollocatedDLinearDiscretisationWithPointJacobi.add_to_create_grid (   self,
  observer 
)

◆ add_to_init_solution()

solvers.api.CollocatedDLinearDiscretisationWithPointJacobi.CollocatedDLinearDiscretisationWithPointJacobi.add_to_init_solution (   self,
  observer 
)

◆ add_to_Peano4_datamodel()

solvers.api.CollocatedDLinearDiscretisationWithPointJacobi.CollocatedDLinearDiscretisationWithPointJacobi.add_to_Peano4_datamodel (   self,
  datamodel,
  verbose 
)

◆ add_to_plot()

solvers.api.CollocatedDLinearDiscretisationWithPointJacobi.CollocatedDLinearDiscretisationWithPointJacobi.add_to_plot (   self,
  observer 
)

Tell the project's observer how to plot the data.

Nothing fancy here. We add plotters from Peano's toolbox to visualise solution and right-hand side.

Definition at line 196 of file CollocatedDLinearDiscretisationWithPointJacobi.py.

References solvers.api.CollocatedDLinearDiscretisationWithPointJacobi.CollocatedDLinearDiscretisationWithPointJacobi._custom_plot_actionset, solvers.api.ContinuousGalerkinDiscretisationGaussLobattoWithBlockJacobi.ContinuousGalerkinDiscretisationGaussLobattoWithBlockJacobi._custom_plot_actionset, solvers.api.DiscontinuousGalerkinDiscretisationPointWiseRiemannSolver.DiscontinuousGalerkinDiscretisationPointWiseRiemannSolver._custom_plot_actionset, solvers.api.CollocatedDLinearDiscretisationWithPointJacobi.CollocatedDLinearDiscretisationWithPointJacobi._enable_plotting, solvers.api.ContinuousGalerkinDiscretisationGaussLobattoWithBlockJacobi.ContinuousGalerkinDiscretisationGaussLobattoWithBlockJacobi._enable_plotting, solvers.api.DiscontinuousGalerkinDiscretisationPointWiseRiemannSolver.DiscontinuousGalerkinDiscretisationPointWiseRiemannSolver._enable_plotting, solvers.api.CollocatedDLinearDiscretisationWithPointJacobi.CollocatedDLinearDiscretisationWithPointJacobi._plot_predicate, solvers.api.CollocatedMG.CollocatedMG._plot_predicate, solvers.api.ContinuousGalerkinDiscretisationGaussLobattoWithBlockJacobi.ContinuousGalerkinDiscretisationGaussLobattoWithBlockJacobi._plot_predicate, and solvers.api.DiscontinuousGalerkinDiscretisationPointWiseRiemannSolver.DiscontinuousGalerkinDiscretisationPointWiseRiemannSolver._plot_predicate.

◆ add_to_solve()

◆ add_use_statements()

solvers.api.CollocatedDLinearDiscretisationWithPointJacobi.CollocatedDLinearDiscretisationWithPointJacobi.add_use_statements (   self,
  observer 
)

This routine should still be called even if overwritten in child class.

Reimplemented from solvers.api.Solver.Solver.

Definition at line 191 of file CollocatedDLinearDiscretisationWithPointJacobi.py.

References solvers.api.CollocatedDLinearDiscretisationWithPointJacobi.CollocatedDLinearDiscretisationWithPointJacobi.add_use_statements().

Referenced by solvers.api.CollocatedDLinearDiscretisationWithPointJacobi.CollocatedDLinearDiscretisationWithPointJacobi.add_use_statements().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_vertex_merge_method()

solvers.api.CollocatedDLinearDiscretisationWithPointJacobi.CollocatedDLinearDiscretisationWithPointJacobi.get_vertex_merge_method (   self)

Field Documentation

◆ _abstract_solver_header_extras

solvers.api.CollocatedDLinearDiscretisationWithPointJacobi.CollocatedDLinearDiscretisationWithPointJacobi._abstract_solver_header_extras
protected

◆ _abstract_solver_implementation_extras

solvers.api.CollocatedDLinearDiscretisationWithPointJacobi.CollocatedDLinearDiscretisationWithPointJacobi._abstract_solver_implementation_extras
protected

◆ _basic_descend_order

◆ _custom_boundary_conditions

solvers.api.CollocatedDLinearDiscretisationWithPointJacobi.CollocatedDLinearDiscretisationWithPointJacobi._custom_boundary_conditions
protected

◆ _custom_init_actionset

◆ _custom_init_vertex

solvers.api.CollocatedDLinearDiscretisationWithPointJacobi.CollocatedDLinearDiscretisationWithPointJacobi._custom_init_vertex
protected

◆ _custom_plot_actionset

◆ _enable_plotting

◆ _local_assembly_matrix

solvers.api.CollocatedDLinearDiscretisationWithPointJacobi.CollocatedDLinearDiscretisationWithPointJacobi._local_assembly_matrix
protected

◆ _local_assembly_matrix_scaling

solvers.api.CollocatedDLinearDiscretisationWithPointJacobi.CollocatedDLinearDiscretisationWithPointJacobi._local_assembly_matrix_scaling
protected

◆ _mass_matrix

solvers.api.CollocatedDLinearDiscretisationWithPointJacobi.CollocatedDLinearDiscretisationWithPointJacobi._mass_matrix
protected

◆ _mass_matrix_scaling

solvers.api.CollocatedDLinearDiscretisationWithPointJacobi.CollocatedDLinearDiscretisationWithPointJacobi._mass_matrix_scaling
protected

◆ _plot_predicate

◆ _smoother_relaxation

solvers.api.CollocatedDLinearDiscretisationWithPointJacobi.CollocatedDLinearDiscretisationWithPointJacobi._smoother_relaxation
protected

◆ _solver_tolerance

solvers.api.CollocatedDLinearDiscretisationWithPointJacobi.CollocatedDLinearDiscretisationWithPointJacobi._solver_tolerance
protected

◆ _unknowns_per_vertex_node

solvers.api.CollocatedDLinearDiscretisationWithPointJacobi.CollocatedDLinearDiscretisationWithPointJacobi._unknowns_per_vertex_node
protected

◆ max_h

solvers.api.CollocatedDLinearDiscretisationWithPointJacobi.CollocatedDLinearDiscretisationWithPointJacobi.max_h

◆ min_h

solvers.api.CollocatedDLinearDiscretisationWithPointJacobi.CollocatedDLinearDiscretisationWithPointJacobi.min_h

The documentation for this class was generated from the following file: