|
DNDSR 0.1.0.dev1+gcd065ad
Distributed Numeric Data Structure for CFV
|
Unit tests for block-sparse LU factorization in Solver/Direct.hpp. More...
#include "doctest.h"#include "DNDS/Defines.hpp"#include "DNDS/MPI.hpp"#include "Solver/Direct.hpp"#include <Eigen/Dense>#include <iostream>#include <iomanip>#include <vector>#include <memory>#include <cmath>Go to the source code of this file.
Classes | |
| struct | TestBlockLU |
| struct | TestBlockLDLT |
Macros | |
| #define | DOCTEST_CONFIG_IMPLEMENT |
Typedefs | |
| using | Block = Eigen::Matrix< real, BS, BS > |
| using | BVec = Eigen::Vector< real, BS > |
| using | tVec = std::vector< BVec > |
| using | tBase = Direct::LocalLUBase< TestBlockLU, Block, tVec > |
| using | tLDLTBase = Direct::LocalLDLTBase< TestBlockLDLT, Block, tVec > |
Functions | |
| TEST_CASE ("Direct 2D periodic: symbolic factorization has fill-in") | |
| TEST_CASE ("Direct 2D periodic: MatMul is correct") | |
| TEST_CASE ("Direct 2D periodic: complete LU solve is exact") | |
| symLU0 | ObtainSymmetricSymbolicFactorization (adj, {0, NCells}, 0) |
| fill2DLaplacian (luOrig) | |
| tVec | x_known (NCells) |
| tVec | b (NCells) |
| tVec | x_ilu (NCells) |
| tVec | Ax_ilu (NCells) |
| for (int i=0;i< NCells;i++) | |
| luOrig | MatMul (x_known, b) |
| fill2DLaplacian (luILU) | |
| luILU | InPlaceDecompose () |
| luILU | Solve (b, x_ilu) |
| fill2DLaplacian (luMul) | |
| luMul | MatMul (x_ilu, Ax_ilu) |
| fill2DLaplacian (luA) | |
| symM | ObtainSymmetricSymbolicFactorization (adj, {0, NCells}, iluCode) |
| fill2DLaplacian (luM) | |
| tVec | x (NCells) |
| tVec | r (NCells) |
| tVec | z (NCells) |
| tVec | Ax (NCells) |
| TEST_CASE ("Direct 2D periodic: ILU(1) converges faster than ILU(0) as preconditioner") | |
| TEST_CASE ("Direct 2D periodic LDLT: MatMul matches LU MatMul for symmetric system") | |
| TEST_CASE ("Direct 2D periodic LDLT: complete decompose + solve is exact") | |
| int | main (int argc, char **argv) |
Variables | |
| auto | adj = build2DPeriodicAdj() |
| auto | symLUorig = std::make_shared<Direct::SerialSymLUStructure>(g_mpi, NCells) |
| TestBlockLU | luOrig (symLUorig, NCells) |
| TestBlockLU | luILU (symLU0, NCells) |
| auto | symLUmul = std::make_shared<Direct::SerialSymLUStructure>(g_mpi, NCells) |
| TestBlockLU | luMul (symLUmul, NCells) |
| real | residualNorm = 0 |
| real | bNorm = 0 |
| real | relResidual = residualNorm / bNorm |
| TestBlockLU | luA (symA, NCells) |
| auto | symM = std::make_shared<Direct::SerialSymLUStructure>(g_mpi, NCells) |
| TestBlockLU | luM (symM, NCells) |
| real | err = 0 |
Unit tests for block-sparse LU factorization in Solver/Direct.hpp.
Tests a 2D periodic Laplacian with 2x2 blocks on an NxN grid: A = 5-point stencil with periodic boundary (4 neighbors per cell). Each cell (i,j) connects to (i±1,j) and (i,j±1) with wrap-around. Diag = 4*I + delta*diag(i,2i), off-diag = -I (non-symmetric diag to exercise the full LU, not just LDLT).
Verifies:
Definition in file test_Direct.cpp.
| #define DOCTEST_CONFIG_IMPLEMENT |
Definition at line 19 of file test_Direct.cpp.
Definition at line 35 of file test_Direct.cpp.
Definition at line 36 of file test_Direct.cpp.
| using tBase = Direct::LocalLUBase<TestBlockLU, Block, tVec> |
Definition at line 43 of file test_Direct.cpp.
| using tLDLTBase = Direct::LocalLDLTBase<TestBlockLDLT, Block, tVec> |
Definition at line 360 of file test_Direct.cpp.
Definition at line 42 of file test_Direct.cpp.
| tVec Ax | ( | NCells | ) |
| tVec Ax_ilu | ( | NCells | ) |
| tVec b | ( | NCells | ) |
| fill2DLaplacian | ( | luA | ) |
| fill2DLaplacian | ( | luILU | ) |
| fill2DLaplacian | ( | luM | ) |
| fill2DLaplacian | ( | luMul | ) |
| fill2DLaplacian | ( | luOrig | ) |
| for | ( | ) |
| luM InPlaceDecompose | ( | ) |
| int main | ( | int | argc, |
| char ** | argv | ||
| ) |
| symA ObtainSymmetricSymbolicFactorization | ( | adj | , |
| {0, NCells} | , | ||
| 0 | |||
| ) |
| tVec r | ( | NCells | ) |
| TEST_CASE | ( | "Direct 2D periodic LDLT: complete decompose + solve is exact" | ) |
| TEST_CASE | ( | "Direct 2D periodic: complete LU solve is exact" | ) |
| TEST_CASE | ( | "Direct 2D periodic: ILU(1) converges faster than ILU(0) as preconditioner" | ) |
| TEST_CASE | ( | "Direct 2D periodic: MatMul is correct" | ) |
| TEST_CASE | ( | "Direct 2D periodic: symbolic factorization has fill-in" | ) |
| tVec x | ( | NCells | ) |
| tVec x_ilu | ( | NCells | ) |
| tVec x_known | ( | NCells | ) |
| tVec z | ( | NCells | ) |
| auto adj = build2DPeriodicAdj() |
Definition at line 229 of file test_Direct.cpp.
| bNorm = 0 |
Definition at line 265 of file test_Direct.cpp.
| real err = 0 |
Definition at line 315 of file test_Direct.cpp.
| TestBlockLU luA(symA, NCells) | ( | symA | , |
| NCells | |||
| ) |
| TestBlockLU luILU(symLU0, NCells) | ( | symLU0 | , |
| NCells | |||
| ) |
| TestBlockLU luM(symM, NCells) | ( | symM | , |
| NCells | |||
| ) |
| TestBlockLU luMul(symLUmul, NCells) | ( | symLUmul | , |
| NCells | |||
| ) |
| TestBlockLU luOrig(symLUorig, NCells) | ( | symLUorig | , |
| NCells | |||
| ) |
| real relResidual = residualNorm / bNorm |
Definition at line 274 of file test_Direct.cpp.
| residualNorm = 0 |
Definition at line 265 of file test_Direct.cpp.
| auto symLUmul = std::make_shared<Direct::SerialSymLUStructure>(g_mpi, NCells) |
Definition at line 259 of file test_Direct.cpp.
| auto symLUorig = std::make_shared<Direct::SerialSymLUStructure>(g_mpi, NCells) |
Definition at line 233 of file test_Direct.cpp.
| auto symM = std::make_shared<Direct::SerialSymLUStructure>(g_mpi, NCells) |
Definition at line 295 of file test_Direct.cpp.