Skip to content
Snippets Groups Projects
Commit 21e3a2fd authored by Axelle Drouard's avatar Axelle Drouard
Browse files

Merge remote-tracking branch 'remotes/origin/feature/Navier-Stokes' into feature/Nodal_diffusion

parents c449803b 704f77c0
Branches
Tags
No related merge requests found
...@@ -12,13 +12,20 @@ class SymmetryBoundaryConditionDescriptor : public IBoundaryConditionDescriptor ...@@ -12,13 +12,20 @@ class SymmetryBoundaryConditionDescriptor : public IBoundaryConditionDescriptor
std::ostream& std::ostream&
_write(std::ostream& os) const final _write(std::ostream& os) const final
{ {
os << "symmetry(" << *m_boundary_descriptor << ")"; os << "symmetry(" << m_name << ',' << *m_boundary_descriptor << ")";
return os; return os;
} }
const std::string_view m_name;
std::shared_ptr<const IBoundaryDescriptor> m_boundary_descriptor; std::shared_ptr<const IBoundaryDescriptor> m_boundary_descriptor;
public: public:
std::string_view
name() const
{
return m_name;
}
const IBoundaryDescriptor& const IBoundaryDescriptor&
boundaryDescriptor() const final boundaryDescriptor() const final
{ {
......
This diff is collapsed.
This diff is collapsed.
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include <algebra/CG.hpp> #include <algebra/CG.hpp>
#include <algebra/CRSMatrix.hpp> #include <algebra/CRSMatrix.hpp>
#include <algebra/CRSMatrixDescriptor.hpp> #include <algebra/CRSMatrixDescriptor.hpp>
#include <algebra/Vector.hpp>
// clazy:excludeall=non-pod-global-static // clazy:excludeall=non-pod-global-static
......
#include <catch2/catch.hpp>
#include <algebra/LeastSquareSolver.hpp>
#include <algebra/LocalRectangularMatrix.hpp>
#include <algebra/Vector.hpp>
// clazy:excludeall=non-pod-global-static
TEST_CASE("LeastSquareSolver", "[algebra]")
{
SECTION("Least Squares [under-determined]")
{
Vector<double> b{3};
b[0] = 1;
b[1] = 0;
b[2] = 0;
LocalRectangularMatrix<double> A{3, 4};
A(0, 0) = 1;
A(0, 1) = 1;
A(0, 2) = 1;
A(0, 3) = 1;
A(1, 0) = 1;
A(1, 1) = -1;
A(1, 2) = 0;
A(1, 3) = 0;
A(2, 0) = 0;
A(2, 1) = 0;
A(2, 2) = 1;
A(2, 3) = -1;
Vector<double> x_exact{4};
x_exact[0] = 0.25;
x_exact[1] = 0.25;
x_exact[2] = 0.25;
x_exact[3] = 0.25;
Vector<double> x{4};
x = 0;
LeastSquareSolver ls_solver;
ls_solver.solveLocalSystem(A, x, b);
Vector error = x - x_exact;
REQUIRE(std::sqrt((error, error)) < 1E-10 * std::sqrt((x, x)));
}
SECTION("Least Squares [over-determined]")
{
LocalRectangularMatrix<double> A{3, 2};
A(0, 0) = 0;
A(0, 1) = 1;
A(1, 0) = 1;
A(1, 1) = 1;
A(2, 0) = 2;
A(2, 1) = 1;
Vector<double> x_exact{2};
x_exact[0] = -3;
x_exact[1] = 5;
Vector b{3};
b[0] = 6;
b[1] = 0;
b[2] = 0;
Vector<double> x{2};
x = 0;
LeastSquareSolver ls_solver;
ls_solver.solveLocalSystem(A, x, b);
Vector error = x - x_exact;
REQUIRE(std::sqrt((error, error)) < 1E-10 * std::sqrt((x_exact, x_exact)));
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment