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

Skip to content

Commit 7db84b2

Browse files
committed
Reformat some of the code bits
1 parent 2d09453 commit 7db84b2

File tree

6 files changed

+60
-23
lines changed

6 files changed

+60
-23
lines changed

.vscode/tasks.json

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@
103103
]
104104
},
105105
{
106-
"label": "debug",
106+
"label": "debug-diffusion_2d",
107107
"type": "shell",
108108
"command": "g++",
109109
"args": [
@@ -135,6 +135,39 @@
135135
"$gcc"
136136
]
137137
},
138+
{
139+
"label": "debug-perovskite",
140+
"type": "shell",
141+
"command": "g++",
142+
"args": [
143+
"-g",
144+
"-Wall",
145+
"-std=c++11",
146+
"-m64",
147+
"-fopenmp",
148+
"./examples/perovskite/*.cpp",
149+
"./src/*.cpp",
150+
"-o",
151+
"dbg.exe",
152+
"-I/opt/intel/mkl/include",
153+
"-I./src/external",
154+
//"-I/usr/include/python3.6m",
155+
//"-I/usr/local/lib/python3.6/dist-packages/numpy/core/include",
156+
//"-lpython3.6m",
157+
"-L/opt/intel/mkl/lib/intel64",
158+
"-Wl,--no-as-needed",
159+
"-lmkl_intel_lp64",
160+
"-lmkl_gnu_thread",
161+
"-lmkl_core",
162+
"-lgomp",
163+
"-lpthread",
164+
"-lm",
165+
"-ldl"
166+
],
167+
"problemMatcher": [
168+
"$gcc"
169+
]
170+
},
138171
{
139172
"label": "build-int-64",
140173
"type": "shell",

clang-tidy.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
clang-tidy src/*.cpp -- -I/opt/intel/mkl/include
22
clang-tidy examples/perovskite/*.cpp -- -I/opt/intel/mkl/include
3+
clang-tidy examples/diffusion_2d/*.cpp -- -I/opt/intel/mkl/include

examples/diffusion_2d/diffusion_2d.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ 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
84+
opt.fact_every_iter = false; // Gain some speed. The matrices will be
85+
// factorized only once each time step.
8686

8787
// We can override Jacobian class from dae-cpp library and provide
8888
// analytical Jacobian. But we will use numerically estimated one.
@@ -198,7 +198,7 @@ int solution_check(dae::state_type &x, MKL_INT N, double t, double D)
198198
}
199199
else
200200
{
201-
error = (x[ind] - an); // absolute error
201+
// error = (x[ind] - an); // absolute error
202202
}
203203
}
204204
}

src/solver.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -210,19 +210,19 @@ void Solver::operator()(state_type &x)
210210
check_pardiso_error(error);
211211
exit(1);
212212
}
213+
} // Reordering and Symbolic Factorization
213214

214-
// PHASE 2.
215-
// Numerical factorization
216-
phase = 22;
217-
PARDISO(pt, &maxfct, &mnum, &mtype, &phase, &size, mkl_a, ia,
218-
ja, &idum, &nrhs, iparm, &msglvl, &ddum, &ddum, &error);
215+
// PHASE 2.
216+
// Numerical factorization
217+
phase = 22;
218+
PARDISO(pt, &maxfct, &mnum, &mtype, &phase, &size, mkl_a, ia, ja,
219+
&idum, &nrhs, iparm, &msglvl, &ddum, &ddum, &error);
219220

220-
if(error != 0)
221-
{
222-
std::cout << "\nERROR during numerical factorization...\n";
223-
check_pardiso_error(error);
224-
exit(2);
225-
}
221+
if(error != 0)
222+
{
223+
std::cout << "\nERROR during numerical factorization...\n";
224+
check_pardiso_error(error);
225+
exit(2);
226226
}
227227

228228
// PHASE 3.

src/solver_options.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class SolverOptions
2424
// speeding up. If MKL_NUM_THREADS is not defined, then the solver uses all
2525
// available processors.
2626

27-
// Perform symbolic and numerical factorisation every Newton iteration
27+
// Perform Reordering and Symbolic Factorization every Newton iteration
2828
// (changing to 'false' can increase speed but also can lead to instability)
2929
bool fact_every_iter = true;
3030

src/time_integrator.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ TimeIntegrator::TimeIntegrator(RHS &rhs, Jacobian &jac, MassMatrix &mass,
2525
if(matrix_checker(m_M, size))
2626
{
2727
std::cout << "Error in Mass matrix.\n";
28-
exit(1);
28+
exit(11);
2929
}
3030

3131
// Init mass matrix descriptor for sparse solver
@@ -54,7 +54,7 @@ TimeIntegrator::TimeIntegrator(RHS &rhs, Jacobian &jac, MassMatrix &mass,
5454
{
5555
std::cout << "ERROR: Could not create sparse matrix descriptor for "
5656
"Mass matrix.\n";
57-
exit(1);
57+
exit(11);
5858
}
5959

6060
// Analyze sparse matrix, choose proper kernels and workload
@@ -80,14 +80,17 @@ void TimeIntegrator::operator()(sparse_matrix_holder &Jt, state_type &b,
8080

8181
state_type dxdt(size);
8282

83-
if(m_scheme == 2 && m_opt.bdf_order == 2) // Variable time stepper for BDF-2
83+
// Variable time stepper for BDF-2
84+
if(m_scheme == 2 && m_opt.bdf_order == 2)
8485
{
8586
for(MKL_INT i = 0; i < size; i++)
8687
{
87-
dxdt[i] = (2.0*dt[0] + dt[1])/(dt[0]*(dt[0] + dt[1])) * x[i] - (dt[0] + dt[1])/(dt[0]*dt[1]) * x_prev[0][i] + dt[0]/(dt[1]*(dt[0] + dt[1])) * x_prev[1][i];
88+
dxdt[i] = (2.0 * dt[0] + dt[1]) / (dt[0] * (dt[0] + dt[1])) * x[i] -
89+
(dt[0] + dt[1]) / (dt[0] * dt[1]) * x_prev[0][i] +
90+
dt[0] / (dt[1] * (dt[0] + dt[1])) * x_prev[1][i];
8891
}
8992

90-
alpha = (2.0*dt[0] + dt[1])/(dt[0]*(dt[0] + dt[1]));
93+
alpha = (2.0 * dt[0] + dt[1]) / (dt[0] * (dt[0] + dt[1]));
9194
}
9295
else // Constant time stepper
9396
{
@@ -130,7 +133,7 @@ void TimeIntegrator::operator()(sparse_matrix_holder &Jt, state_type &b,
130133
if(matrix_checker(J, size))
131134
{
132135
std::cout << "Error in Jacobian matrix.\n";
133-
exit(1);
136+
exit(12);
134137
}
135138

136139
size_t nzmax = m_M.A.size() + J.A.size();

0 commit comments

Comments
 (0)