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
 __init__ (self, name, min_h, max_h)
 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)

Protected Attributes

 _unknowns_per_vertex_node = unknowns_per_vertex
 _local_assembly_matrix = local_assembly_matrix
 _local_assembly_matrix_scaling = local_assembly_matrix_scaling
 _mass_matrix = mass_matrix
 _mass_matrix_scaling = mass_matrix_scaling
 _solver_tolerance = solver_tolerance
int _basic_descend_order = 0
 _smoother_relaxation = smoother_relaxation
 _custom_init_actionset = custom_init_actionset
 _custom_plot_actionset = custom_plot_actionset
 _custom_init_vertex = custom_init_vertex
 _custom_boundary_conditions = custom_boundary_conditions
# true by default _enable_plotting = enable_plotting
 _plot_predicate = plot_predicate
Protected Attributes inherited from solvers.api.Solver.Solver
 _name = name
 _vertex_data = peano4.api.datamodel.DaStGen2( name )
 _face_data = peano4.api.datamodel.DaStGen2( name )
 _cell_data = peano4.api.datamodel.DaStGen2( name )
str _abstract_solver_header_extras = """ """
str _abstract_solver_implementation_extras = """ """

Additional Inherited Members

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

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" )

Collocated low-order (d-linear) Finite Elements.

Definition at line 115 of file CollocatedDLinearDiscretisationWithPointJacobi.py.

References __init__(), solvers.api.Solver.Solver._vertex_data, and get_vertex_merge_method().

Referenced by __init__().

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

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__, peano4.api.output.TemplatedHeaderFile.TemplatedHeaderFile.__class__, solvers.api.Solver.Solver._abstract_solver_header_extras, solvers.api.Solver.Solver._abstract_solver_implementation_extras, _custom_boundary_conditions, _custom_init_vertex, _local_assembly_matrix, _local_assembly_matrix_scaling, _mass_matrix, _mass_matrix_scaling, dastgen2.attributes.Attribute.Attribute._name, dastgen2.attributes.BooleanArray.BooleanArray._name, dastgen2.attributes.Enumeration.Enumeration._name, exagrype.api.euler.CCZ4WithEuler_OuterAdditiveCoupling.CCZ4WithEuler_OuterAdditiveCoupling._name, exagrype.api.euler.CCZ4WithEuler_OuterMultiplicativeCoupling.CCZ4WithEuler_OuterMultiplicativeCoupling._name, exagrype.api.FOSOSolver.FOSOSolver._name, exagrype.api.scalarfield.CCZ4WithScalarField_InnerCoupling.CCZ4WithScalarField_InnerCoupling._name, exagrype.api.scalarfield.CCZ4WithScalarField_OuterMultiplicativeCoupling.CCZ4WithScalarField_OuterMultiplicativeCoupling._name, exahype2.api.AuxiliaryVariables.AuxiliaryVariables._name, exahype2.api.dslhype.SyntaxTree.Construction._name, exahype2.api.dslhype.SyntaxTree.DataBlockConstructionFromDotProduct._name, exahype2.api.dslhype.SyntaxTree.DataBlockConstructionFromExisting._name, exahype2.api.dslhype.SyntaxTree.DataBlockConstructionFromFunction._name, exahype2.api.dslhype.SyntaxTree.DataBlockConstructionFromMatrixVectorProduct._name, exahype2.api.dslhype.SyntaxTree.DataBlockConstructionFromOperation._name, exahype2.api.dslhype.SyntaxTree.MemoryAllocation._name, exahype2.api.dslhype.SyntaxTree.MemoryDeallocation._name, exahype2.api.Solver.Solver._name, solvers.api.Solver.Solver._name, _smoother_relaxation, _solver_tolerance, _unknowns_per_vertex_node, exaparty.api.particle.Particle.Particle.max_h, max_h, exaparty.api.particle.Particle.Particle.min_h, solvers.api.Solver.Solver.min_h, and solvers.api.Solver.Solver.typename().

Here is the call graph for this function:

◆ 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 )

Solution initialisation.

We can either use the standard initialisation procedure or pass in another one when we instantiate this solver class.

Definition at line 231 of file CollocatedDLinearDiscretisationWithPointJacobi.py.

References _custom_init_actionset.

◆ add_to_Peano4_datamodel()

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

Reimplemented from solvers.api.Solver.Solver.

Definition at line 186 of file CollocatedDLinearDiscretisationWithPointJacobi.py.

References add_to_Peano4_datamodel().

Referenced by add_to_Peano4_datamodel().

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

◆ 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 _custom_plot_actionset, _enable_plotting, and _plot_predicate.

◆ add_to_solve()

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

◆ 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 add_use_statements().

Referenced by 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)

Definition at line 331 of file CollocatedDLinearDiscretisationWithPointJacobi.py.

References solvers.api.Solver.Solver.typename().

Referenced by __init__().

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

Field Documentation

◆ _basic_descend_order

◆ _custom_boundary_conditions

solvers.api.CollocatedDLinearDiscretisationWithPointJacobi.CollocatedDLinearDiscretisationWithPointJacobi._custom_boundary_conditions = custom_boundary_conditions
protected

◆ _custom_init_actionset

solvers.api.CollocatedDLinearDiscretisationWithPointJacobi.CollocatedDLinearDiscretisationWithPointJacobi._custom_init_actionset = custom_init_actionset
protected

◆ _custom_init_vertex

solvers.api.CollocatedDLinearDiscretisationWithPointJacobi.CollocatedDLinearDiscretisationWithPointJacobi._custom_init_vertex = custom_init_vertex
protected

◆ _custom_plot_actionset

solvers.api.CollocatedDLinearDiscretisationWithPointJacobi.CollocatedDLinearDiscretisationWithPointJacobi._custom_plot_actionset = custom_plot_actionset
protected

◆ _enable_plotting

# true by default solvers.api.CollocatedDLinearDiscretisationWithPointJacobi.CollocatedDLinearDiscretisationWithPointJacobi._enable_plotting = enable_plotting
protected

◆ _local_assembly_matrix

solvers.api.CollocatedDLinearDiscretisationWithPointJacobi.CollocatedDLinearDiscretisationWithPointJacobi._local_assembly_matrix = local_assembly_matrix
protected

◆ _local_assembly_matrix_scaling

solvers.api.CollocatedDLinearDiscretisationWithPointJacobi.CollocatedDLinearDiscretisationWithPointJacobi._local_assembly_matrix_scaling = local_assembly_matrix_scaling
protected

◆ _mass_matrix

◆ _mass_matrix_scaling

◆ _plot_predicate

solvers.api.CollocatedDLinearDiscretisationWithPointJacobi.CollocatedDLinearDiscretisationWithPointJacobi._plot_predicate = plot_predicate
protected

◆ _smoother_relaxation

solvers.api.CollocatedDLinearDiscretisationWithPointJacobi.CollocatedDLinearDiscretisationWithPointJacobi._smoother_relaxation = smoother_relaxation
protected

◆ _solver_tolerance

◆ _unknowns_per_vertex_node

solvers.api.CollocatedDLinearDiscretisationWithPointJacobi.CollocatedDLinearDiscretisationWithPointJacobi._unknowns_per_vertex_node = unknowns_per_vertex
protected

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