Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3bb9d48

Browse files
committed
Added single precision test. Examples now work in both double and single precision.
1 parent 8eff155 commit 3bb9d48

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

examples/diffusion_2d/diffusion_2d.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,7 @@ int main()
8080
// parameters defined in solver_options.h
8181
dae::SolverOptions opt;
8282

83-
opt.dt_init = 5.0e-5; // Change initial time step
84-
opt.fact_every_iter = false; // Gain some speed. The matrices will be
85-
// factorized only once each time step.
83+
opt.dt_init = 5.0e-5; // Change initial time step
8684

8785
// We can override Jacobian class from dae-cpp library and provide
8886
// analytical Jacobian. But we will use numerically estimated one.
@@ -211,7 +209,11 @@ int solution_check(dae::state_type &x, MKL_INT N, double t, double D)
211209
<< "% deviation from the analytical value)\n";
212210
std::cout << "Maximum relative error: " << err_max << "%\n";
213211

214-
if(err_max < 1.0 && err_conc < 1.0e-6)
212+
#ifdef DAE_SINGLE
213+
if(err_max < 1.0 && err_conc < 1.0e-5)
214+
#else
215+
if(err_max < 1.0 && err_conc < 1.0e-10)
216+
#endif
215217
return 0;
216218
else
217219
return 1;

examples/perovskite/perovskite.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,7 @@ int main()
9999
// parameters defined in solver_options.h
100100
dae::SolverOptions opt;
101101

102-
opt.time_stepping = 1; // Choose Stability-based time stepper
103-
opt.fact_every_iter = false; // Gain some speed. The matrices will be
104-
// factorized only once each time step.
102+
opt.time_stepping = 1; // Choose Stability-based time stepper
105103

106104
// Create an instance of the solver with particular RHS, Mass matrix,
107105
// Jacobian and solver options

test_single.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
rm -r build/
2+
mkdir build
3+
cd build
4+
cmake -DDAE_SINGLE=ON ..
5+
make -j 4
6+
ctest

0 commit comments

Comments
 (0)