Skip to content

Conversation

@rubenzorrilla
Copy link
Member

📝 Description
In this PR I'm introducing the LinearOperator classes in #14110 to the future environment, namely strategies, schemes, builders and linear solvers.

Note that I also took the chance to rename the LinearSystemContainer to ImplicitStrategyDataContainer, something that is much more self-descriptive IMO.

This requires #14108 and #14110 to be merged first but I'd like to create it as a draft PR to start the discussion and triggering the CI.

///@{

/**
* @brief
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Repeated and empty

Suggested change
* @brief

TMatrixType& GetMatrix()
{
KRATOS_ERROR_IF(this->IsMatrixFree()) << "Trying to access matrix from a matrix-free LinearOperator." << std::endl;
auto r_matrix = this->GetMatrixImpl(); // Get the underlying matrix as std::any
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

&?

Suggested change
auto r_matrix = this->GetMatrixImpl(); // Get the underlying matrix as std::any
auto& r_matrix = this->GetMatrixImpl(); // Get the underlying matrix as std::any

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, you do a cast later, remove the r?

const TMatrixType& GetMatrix() const
{
KRATOS_ERROR_IF(this->IsMatrixFree()) << "Trying to access matrix from a matrix-free LinearOperator." << std::endl;
const auto r_matrix = this->GetMatrixImpl(); // Get the underlying matrix as const std::any
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idem

* AMGCL is a header-only C++ library for solving large sparse linear systems with algebraic multigrid (AMG) method. AMG is one of the most effective iterative methods for solution of equation systems arising, for example, from discretizing PDEs on unstructured grids. The method can be used as a black-box solver for various computational problems, since it does not require any information about the underlying geometry. AMG is often used not as a standalone solver but as a preconditioner within an iterative solver (e.g. Conjugate Gradients, BiCGStab, or GMRES).
* AMGCL builds the AMG hierarchy on a CPU and then transfers it to one of the provided backends. This allows for transparent acceleration of the solution phase with help of OpenCL, CUDA, or OpenMP technologies. Users may provide their own backends which enables tight integration between AMGCL and the user code.
* @author Denis Demidov
* @author Pooyan Dadvand
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And Denis?

@@ -23,6 +22,7 @@
// Project includes
#include "includes/define.h"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be safely removed

Suggested change
#include "includes/define.h"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any case now with C++20 we can use the modules to reduce compilations times and avoid the infinite nested includes

@@ -22,6 +22,7 @@
// Project includes
#include "includes/define.h"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#include "includes/define.h"

@@ -22,6 +22,7 @@
// Project includes
#include "includes/define.h"
#include "includes/model_part.h"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#include "includes/model_part.h"

Linear operator already includes it


// Project includes
#include "future/linear_solvers/direct_solver.h"
#include "includes/define.h"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#include "includes/define.h"

#include "containers/csr_matrix.h"
#include "containers/system_vector.h"
#include "containers/sparse_contiguous_row_graph.h"
#include "includes/define.h"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#include "includes/define.h"

#include "containers/csr_matrix.h"
#include "containers/system_vector.h"
#include "containers/sparse_contiguous_row_graph.h"
#include "includes/define.h"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#include "includes/define.h"

{
public:

// FIXME: Does not work... ask @Charlie
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@loumalouomega loumalouomega left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments

@philbucher
Copy link
Member

This looks cool. In fact I was also looking into this lately. Matrix free only works with iterative solvers right? Does amgcl support it?

@RiccardoRossi
Copy link
Member

This looks cool. In fact I was also looking into this lately. Matrix free only works with iterative solvers right? Does amgcl support it?

yes, it only works with krylov solvers. The problem is that typically it is impossible to mount a preconditioner. No ... AMGCL does not support it...

cool thing is that you can also use to mount a GMRES-krylov solver for nonlinear problem

@philbucher
Copy link
Member

yes, it only works with krylov solvers.

is it worth it then? Seems that you are doing substantial changes to accommodate it. (I have no idea, just curious)

@RiccardoRossi
Copy link
Member

Linear Operators are a nice thing to have, but they are not the reason of being of the reorganization we are doing.

rather we are revamping the strategy/solver design to be more modular and to better consider parallelism (for exampel mpi will now be native) and the application of constraints

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants