const VECTOR &diagonal_vector;
};
+
+ struct EigenvalueTracker
+ {
+ public:
+ void slot(const std::vector<double> &eigenvalues)
+ {
+ values = eigenvalues;
+ }
+
+ std::vector<double> values;
+ };
}
}
Assert (additional_data.eig_cg_n_iterations > 2,
ExcMessage ("Need to set at least two iterations to find eigenvalues."));
- // attach stream to SolverCG, run it with log report for eigenvalues
- std::ostream *old_stream = deallog.has_file() ? &deallog.get_file_stream() :
- static_cast<std::ostream *>(0);
- if (old_stream)
- deallog.detach();
-
- std::ostringstream log_msg;
- deallog.attach(log_msg);
-
// set a very strict tolerance to force at least two iterations
ReductionControl control (data.eig_cg_n_iterations, 1e-20, 1e-20);
GrowingVectorMemory<VECTOR> memory;
dummy->reinit(data.matrix_diagonal_inverse);
*rhs = 1./std::sqrt(static_cast<double>(matrix.m()));
- typename SolverCG<VECTOR>::AdditionalData cg_data;
- cg_data.compute_eigenvalues = true;
- SolverCG<VECTOR> solver (control, memory, cg_data);
+ internal::PreconditionChebyshev::EigenvalueTracker eigenvalue_tracker;
+ SolverCG<VECTOR> solver (control, memory);
+ solver.connect_eigenvalues_slot(std_cxx11::bind(&internal::PreconditionChebyshev::EigenvalueTracker::slot,
+ &eigenvalue_tracker,
+ std_cxx11::_1));
internal::PreconditionChebyshev::DiagonalPreconditioner<VECTOR>
preconditioner(data.matrix_diagonal_inverse);
try
memory.free(dummy);
memory.free(rhs);
- // read the log stream: grab the first and last eigenvalue
- std::string cg_message = log_msg.str();
- const std::size_t pos = cg_message.find("cg:: ");
- if (pos != std::string::npos)
+ // read the eigenvalues from the attached eigenvalue tracker
+ if (eigenvalue_tracker.values.empty())
+ min_eigenvalue = max_eigenvalue = 1;
+ else
{
- cg_message.erase(0, pos+5);
- std::string first = cg_message;
-
- if (cg_message.find_first_of(" ") != std::string::npos)
- first.erase(cg_message.find_first_of(" "), std::string::npos);
- std::istringstream(first) >> min_eigenvalue;
-
- if (cg_message.find_last_of(" ") != std::string::npos)
- {
- cg_message.erase(0, cg_message.find_last_of(" ")+1);
- std::istringstream(cg_message) >> max_eigenvalue;
- }
- else max_eigenvalue = min_eigenvalue;
+ min_eigenvalue = eigenvalue_tracker.values.front();
+ max_eigenvalue = eigenvalue_tracker.values.back();
}
- else
- min_eigenvalue = max_eigenvalue = 1;
-
- // reset deal.II stream
- deallog.detach();
- if (old_stream)
- deallog.attach(*old_stream);
// include a safety factor since the CG method will in general not be
// converged
-
+DEAL:cg::Starting value 1.00
+DEAL:cg::Convergence step 2 value 0
DEAL::Exact inverse: 0.84 0.20 0.26 0.20 0.18 0.03 0.05 0.10 0.03 0.06
DEAL::Check vmult orig: 1.09 0.26 0.34 0.26 0.24 0.04 0.06 0.12 0.04 0.07
DEAL::Check Tvmult orig: 1.09 0.26 0.34 0.26 0.24 0.04 0.06 0.12 0.04 0.07
-
+DEAL:cg::Starting value 1.00
+DEAL:cg::Failure step 8 value 0.00
DEAL::Check vmult diag: 0.82 0.26 0.33 0.21 0.15 0.02 0.03 0.09 0.03 0.07
DEAL::Check Tvmult diag: 0.82 0.26 0.33 0.21 0.15 0.02 0.03 0.09 0.03 0.07
DEAL:2d::Cycle 0
DEAL:2d::Number of degrees of freedom: 81
-
-
-
+DEAL:2d:cg::Starting value 1.00
+DEAL:2d:cg::Convergence step 3 value 0
+DEAL:2d:cg::Starting value 1.00
+DEAL:2d:cg::Failure step 10 value 0
+DEAL:2d:cg::Starting value 1.00
+DEAL:2d:cg::Failure step 10 value 0.00110
DEAL:2d:cg::Starting value 0.132
DEAL:2d:cg::Convergence step 4 value 0
DEAL:2d::
DEAL:2d::Cycle 1
DEAL:2d::Number of degrees of freedom: 289
-
-
-
-
+DEAL:2d:cg::Starting value 1.00
+DEAL:2d:cg::Convergence step 3 value 0
+DEAL:2d:cg::Starting value 1.00
+DEAL:2d:cg::Failure step 10 value 0
+DEAL:2d:cg::Starting value 1.00
+DEAL:2d:cg::Failure step 10 value 0.00110
+DEAL:2d:cg::Starting value 1.00
+DEAL:2d:cg::Failure step 10 value 0.153
DEAL:2d:cg::Starting value 0.0677
DEAL:2d:cg::Convergence step 5 value 0
DEAL:2d::
DEAL:2d::Cycle 2
DEAL:2d::Number of degrees of freedom: 1089
-
-
-
-
-
+DEAL:2d:cg::Starting value 1.00
+DEAL:2d:cg::Convergence step 3 value 0
+DEAL:2d:cg::Starting value 1.00
+DEAL:2d:cg::Failure step 10 value 0
+DEAL:2d:cg::Starting value 1.00
+DEAL:2d:cg::Failure step 10 value 0.00110
+DEAL:2d:cg::Starting value 1.00
+DEAL:2d:cg::Failure step 10 value 0.153
+DEAL:2d:cg::Starting value 1.00
+DEAL:2d:cg::Failure step 10 value 1.07
DEAL:2d:cg::Starting value 0.0343
DEAL:2d:cg::Convergence step 5 value 0
DEAL:2d::
DEAL:3d::Cycle 0
DEAL:3d::Number of degrees of freedom: 125
-
-
+DEAL:3d:cg::Starting value 1.00
+DEAL:3d:cg::Convergence step 3 value 0
+DEAL:3d:cg::Starting value 1.00
+DEAL:3d:cg::Failure step 10 value 0
DEAL:3d:cg::Starting value 0.125
DEAL:3d:cg::Convergence step 5 value 0
DEAL:3d::
DEAL:3d::Cycle 1
DEAL:3d::Number of degrees of freedom: 729
-
-
-
+DEAL:3d:cg::Starting value 1.00
+DEAL:3d:cg::Convergence step 3 value 0
+DEAL:3d:cg::Starting value 1.00
+DEAL:3d:cg::Failure step 10 value 0
+DEAL:3d:cg::Starting value 1.00
+DEAL:3d:cg::Failure step 10 value 0.000695
DEAL:3d:cg::Starting value 0.0479
DEAL:3d:cg::Convergence step 4 value 0
DEAL:3d::
DEAL:3d::Cycle 2
DEAL:3d::Number of degrees of freedom: 4913
-
-
-
-
+DEAL:3d:cg::Starting value 1.00
+DEAL:3d:cg::Convergence step 3 value 0
+DEAL:3d:cg::Starting value 1.00
+DEAL:3d:cg::Failure step 10 value 0
+DEAL:3d:cg::Starting value 1.00
+DEAL:3d:cg::Failure step 10 value 0.000695
+DEAL:3d:cg::Starting value 1.00
+DEAL:3d:cg::Failure step 10 value 0.0952
DEAL:3d:cg::Starting value 0.0176
DEAL:3d:cg::Convergence step 4 value 0
DEAL:3d::