16 setTolerances(
size_t nr,
const doublereal* rtol,
17 size_t na,
const doublereal* atol,
int ts)
19 if (nr < m_nv || na < m_nv)
21 "wrong array size for solution error tolerances. "
22 "Size should be at least "+
int2str(m_nv));
24 copy(rtol, rtol + m_nv, m_rtol_ss.begin());
25 copy(atol, atol + m_nv, m_atol_ss.begin());
28 copy(rtol, rtol + m_nv, m_rtol_ts.begin());
29 copy(atol, atol + m_nv, m_atol_ts.begin());
34 setTolerances(
size_t n, doublereal rtol, doublereal atol,
int ts)
47 setTolerances(doublereal rtol, doublereal atol,
int ts)
49 for (
size_t n = 0; n < m_nv; n++) {
62 setTolerancesTS(doublereal rtol, doublereal atol)
64 for (
size_t n = 0; n < m_nv; n++) {
71 setTolerancesSS(doublereal rtol, doublereal atol)
73 for (
size_t n = 0; n < m_nv; n++) {
80 eval(
size_t jg, doublereal* xg, doublereal* rg,
81 integer* mask, doublereal rdt)
84 if (jg !=
npos && (jg + 1 < firstPoint() || jg > lastPoint() + 1)) {
94 doublereal* x = xg + loc();
95 doublereal* rsd = rg + loc();
96 integer* diag = mask + loc();
98 size_t jmin, jmax, jpt, j, i;
99 jpt = jg - firstPoint();
105 jmin = std::max<size_t>(jpt, 1) - 1;
109 for (j = jmin; j <= jmax; j++) {
110 if (j == 0 || j == m_points - 1) {
111 for (i = 0; i < m_nv; i++) {
112 rsd[index(i,j)] = residual(x,i,j);
113 diag[index(i,j)] = 0;
116 for (i = 0; i < m_nv; i++) {
117 rsd[index(i,j)] = residual(x,i,j)
118 - timeDerivativeFlag(i)*rdt*(value(x,i,j) - prevSoln(i,j));
119 diag[index(i,j)] = timeDerivativeFlag(i);
127 void Domain1D::setupGrid(
size_t n,
const doublereal* z)
131 for (
size_t j = 0; j < m_points; j++) {
140 writelog(
"\n-------------------------------------"
141 "------------------------------------------");
148 void Domain1D::showSolution(
const doublereal* x)
155 for (i = 0; i < nn; i++) {
157 sprintf(buf,
"\n z ");
159 for (n = 0; n < 5; n++) {
160 sprintf(buf,
" %10s ",componentName(i*5 + n).c_str());
164 for (j = 0; j < m_points; j++) {
165 sprintf(buf,
"\n %10.4g ",m_z[j]);
167 for (n = 0; n < 5; n++) {
168 v = value(x, i*5+n, j);
169 sprintf(buf,
" %10.4g ",v);
175 size_t nrem = m_nv - 5*nn;
177 sprintf(buf,
"\n z ");
179 for (n = 0; n < nrem; n++) {
180 sprintf(buf,
" %10s ", componentName(nn*5 + n).c_str());
184 for (j = 0; j < m_points; j++) {
185 sprintf(buf,
"\n %10.4g ",m_z[j]);
187 for (n = 0; n < nrem; n++) {
188 v = value(x, nn*5+n, j);
189 sprintf(buf,
" %10.4g ", v);
198 void Domain1D::_getInitialSoln(doublereal* x)
200 for (
size_t j = 0; j < m_points; j++) {
201 for (
size_t n = 0; n < m_nv; n++) {
202 x[index(n,j)] = initialValue(n,j);
207 doublereal Domain1D::initialValue(
size_t n,
size_t j)
210 "base class method called!");