Skip to content

Commit

Permalink
reduce tests to minimal not running example and add debug prints
Browse files Browse the repository at this point in the history
  • Loading branch information
jbreue16 committed Oct 22, 2024
1 parent 9ac4df6 commit 3a48754
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ jobs:
${INSTALL_PREFIX}/bin/cadet-cli LWE.h5 || true
- name: Run tests
run: |
${BUILD_DIR}/test/testRunner [CI]
${BUILD_DIR}/test/testRunner [testHere]
MacOS:
runs-on: macos-latest
strategy:
Expand Down
18 changes: 18 additions & 0 deletions src/libcadet/model/GeneralRateModelDG.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
#include <array>
#include <vector>

#include <iostream>
#include <type_traits>

#include "Benchmark.hpp"

using namespace Eigen;
Expand Down Expand Up @@ -417,7 +420,13 @@ class GeneralRateModelDG : public UnitOperationBase
for (int cell = 0; cell < nParCell[parType]; cell++)
{
Ir[offsetMetric[parType] + cell].resize(nParNode[parType]);
std::cout << "jojo:\n";
for (int i = 0; i < 80; i++)
std::cout << Ir[offsetMetric[0] + 0][0].getADValue(i) << std::endl;
Ir[offsetMetric[parType] + cell].setZero();
std::cout << "jojo:\n";
for (int i = 0; i < 80; i++)
std::cout << Ir[offsetMetric[0] + 0][0].getADValue(i) << std::endl;
Dr[offsetMetric[parType] + cell].resize(nParNode[parType], nParNode[parType]);
Dr[offsetMetric[parType] + cell].setZero();
}
Expand Down Expand Up @@ -1013,6 +1022,15 @@ class GeneralRateModelDG : public UnitOperationBase
);
}
else if (_parGeomSurfToVol[parType] == _disc.SurfVolRatioSphere) { // weak surface integral -> M^-1 B [- state*] and B has two non-zero entries, which depend on metrics

if (std::is_same<ResidualType, active>::value)
{
std::cout << "jojo:\n";
for (int i = 0; i < 80; i++)
std::cout << _disc.Ir[_disc.offsetMetric[parType] + Cell][0].getADValue(i) << std::endl;
}


stateDer[Cell * strideCell + Node * strideNode]
-= static_cast<ResidualType>(
_disc.Ir[_disc.offsetMetric[parType] + Cell][0] * _disc.parInvMM[_disc.offsetMetric[parType] + Cell](Node, 0) * (-_surfFluxPar[Cell])
Expand Down
28 changes: 14 additions & 14 deletions test/GeneralRateModelDG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@
#include "Utils.hpp"
#include "common/Driver.hpp"

TEST_CASE("GRM_DG LWE forward vs backward flow", "[GRM],[DG],[Simulation],[CI]")
TEST_CASE("GRM_DG LWE forward vs backward flow", "[GRM],[DG],[Simulation],[CI],[testHere]")
{
cadet::test::column::DGparams disc;
//cadet::test::column::DGparams disc(0, 2, 2, 1, 1);

// Test all integration modes
for (int i = 0; i <= 1; i++)
for (int i = 0; i < 1; i++)
{
disc.setIntegrationMode(i);
cadet::test::column::testForwardBackward("GENERAL_RATE_MODEL", disc, 1e-9, 2e-4);
Expand All @@ -51,18 +52,17 @@ TEST_CASE("GRM_DG non-binding linear pulse vs analytic solution", "[GRM],[DG],[S
cadet::test::column::testAnalyticNonBindingBenchmark("GENERAL_RATE_MODEL", "/data/grm-nonBinding.data", false, disc, 6e-5, 1e-7);
}

// todo FIX (scheitert bei backward flow jacobian vs AD)
//TEST_CASE("GRM_DG Jacobian forward vs backward flow", "[GRM],[DG],[UnitOp],[Residual],[Jacobian],[AD],[todo]")
//{
// cadet::test::column::DGparams disc;
//
// // Test all integration modes
// for (int i = 0; i <= 1; i++)
// {
// disc.setIntegrationMode(i);
// cadet::test::column::testJacobianForwardBackward("GENERAL_RATE_MODEL", disc, std::numeric_limits<float>::epsilon() * 100.0);
// }
//}
TEST_CASE("GRM_DG Jacobian forward vs backward flow", "[GRM],[DG],[UnitOp],[Residual],[Jacobian],[AD],[testHere]")
{
cadet::test::column::DGparams disc(0, 1, 2, 1, 1);

// Test all integration modes
for (int i = 0; i < 1; i++)
{
disc.setIntegrationMode(i);
cadet::test::column::testJacobianForwardBackward("GENERAL_RATE_MODEL", disc, 2.0); // note: integration mode 0 works fine for AD test, but fails for FD pattern comparison
}
}

TEST_CASE("GRM_DG numerical Benchmark with parameter sensitivities for linear case", "[GRM],[DG],[Simulation],[Reference],[Sensitivity]") // todo CI flag: currently only runs locally but fails on server
{
Expand Down

0 comments on commit 3a48754

Please sign in to comment.