forked from 1b-agent/fieldcraft-upstream
Report factor value bytes and preserve overflow-safe reduction limits
This commit is contained in:
1 parent
c7d0a82079
commit
a530a0d914
7 files changed
+80
-12
No files matched your search
@@ -266,9 +266,7 @@ pub(crate) fn factor_symmetric(a: &Csr, limits: &Limits, kind: Kind) -> std::res
|
||||
/// a singular pivot.
|
||||
pub(crate) fn factor_error(e: FactorError, mesh: &Mesh, reduction: &Reduction) -> Error {
|
||||
match e {
|
||||
FactorError::TooLarge { entries, limit } => {
|
||||
Error::Limit(format!("the factorization needs {entries} entries; the limit is {limit} (refine less or raise the limit)"))
|
||||
}
|
||||
FactorError::TooLarge { entries, limit } => Error::factor_limit(entries, limit),
|
||||
FactorError::OutOfMemory { entries } => Error::Limit(format!("not enough memory for the factorization ({entries} entries)")),
|
||||
FactorError::Internal(what) => Error::Internal(what),
|
||||
FactorError::Cancelled => Error::Model(fieldcraft_model::Error::Cancelled),
|
||||
@@ -733,3 +731,20 @@ impl StepResult {
|
||||
.map(Location::Point)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn raised_factor_budget_keeps_the_lanczos_vector_limit() {
|
||||
let neq = Limits::MAX_DOFS;
|
||||
for (entries, expected) in [(400_000_000, 33), (2_000_000_000, 166)] {
|
||||
let limits = Limits { max_factor_entries: entries, ..Limits::default() };
|
||||
let vectors = lanczos_basis(&limits, neq);
|
||||
assert_eq!(vectors, expected);
|
||||
assert!(2 * neq * vectors <= entries);
|
||||
assert_eq!(lanczos_basis(&Limits { max_lanczos_vectors: 7, ..limits }, neq), 7);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user