Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
AlephParams.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/* AlephParams.cc (C) 2010 */
9/* */
10/*---------------------------------------------------------------------------*/
11/*---------------------------------------------------------------------------*/
12
13#include "arcane/aleph/AlephArcane.h"
14
15/*---------------------------------------------------------------------------*/
16/*---------------------------------------------------------------------------*/
17
18namespace Arcane
19{
20
21/*---------------------------------------------------------------------------*/
22/*---------------------------------------------------------------------------*/
23
24AlephParams::
25AlephParams()
26: TraceAccessor(nullptr)
27, m_param_epsilon(1.0e-10)
28, m_param_max_iteration(1024)
29, m_param_preconditioner_method(TypesSolver::DIAGONAL)
30, m_param_solver_method(TypesSolver::PCG)
31, m_param_gamma(-1)
32, m_param_alpha(-1.0)
33, m_param_xo_user(false)
34, m_param_check_real_residue(false)
35, m_param_print_real_residue(false)
36, m_param_debug_info(false)
37, m_param_min_rhs_norm(1.e-20)
38, m_param_convergence_analyse(false)
39, m_param_stop_error_strategy(true)
40, m_param_write_matrix_to_file_error_strategy(false)
41, m_param_write_matrix_name_error_strategy("SolveErrorAlephMatrix.dbg")
42, m_param_listing_output(false)
43, m_param_threshold(0.0)
44, m_param_print_cpu_time_resolution(false)
45, m_param_amg_coarsening_method(0)
46, m_param_output_level(0)
47, m_param_amg_cycle(1)
48, m_param_amg_solver_iterations(1)
49, m_param_amg_smoother_iterations(1)
50, m_param_amg_smootherOption(TypesSolver::SymHybGSJ_smoother)
51, m_param_amg_coarseningOption(TypesSolver::ParallelRugeStuben)
52, m_param_amg_coarseSolverOption(TypesSolver::CG_coarse_solver)
53, m_param_keep_solver_structure(false)
54, m_param_sequential_solver(false)
55, m_param_criteria_stop(TypesSolver::RB)
56{
57 //debug() << "\33[1;4;33m\t[AlephParams] New"<<"\33[0m";
58}
59
60AlephParams::
61AlephParams(ITraceMng* tm,
62 Real epsilon, // convergence epsilon
63 Integer max_iteration, // max number of iterations
64 TypesSolver::ePreconditionerMethod preconditioner_method, // preconditioner used (default DIAG)
65 TypesSolver::eSolverMethod solver_method, // default solution method PCG
66 Integer gamma, // intended for preconditioner parameterization
67 Real alpha, // intended for preconditioner parameterization
68 bool xo_user, // allows the user to initialize PGC with an Xo different from zero
69 bool check_real_residue,
70 bool print_real_residue,
71 bool debug_info,
72 Real min_rhs_norm,
73 bool convergence_analyse,
74 bool stop_error_strategy,
75 bool write_matrix_to_file_error_strategy,
76 String write_matrix_name_error_strategy,
77 bool listing_output,
78 Real threshold,
79 bool print_cpu_time_resolution,
80 Integer amg_coarsening_method,
81 Integer output_level,
82 Integer amg_cycle,
83 Integer amg_solver_iterations,
84 Integer amg_smoother_iterations,
85 TypesSolver::eAmgSmootherOption amg_smootherOption,
86 TypesSolver::eAmgCoarseningOption amg_coarseningOption,
87 TypesSolver::eAmgCoarseSolverOption amg_coarseSolverOption,
88 bool keep_solver_structure,
89 bool sequential_solver,
90 TypesSolver::eCriteriaStop param_criteria_stop)
91: TraceAccessor(tm)
92, m_param_epsilon(epsilon)
93, m_param_max_iteration(max_iteration)
94, m_param_preconditioner_method(preconditioner_method)
95, m_param_solver_method(solver_method)
96, m_param_gamma(gamma)
97, m_param_alpha(alpha)
98, m_param_xo_user(xo_user)
99, m_param_check_real_residue(check_real_residue)
100, m_param_print_real_residue(print_real_residue)
101, m_param_debug_info(debug_info)
102, m_param_min_rhs_norm(min_rhs_norm)
103, m_param_convergence_analyse(convergence_analyse)
104, m_param_stop_error_strategy(stop_error_strategy)
105, m_param_write_matrix_to_file_error_strategy(write_matrix_to_file_error_strategy)
106, m_param_write_matrix_name_error_strategy(write_matrix_name_error_strategy)
107, m_param_listing_output(listing_output)
108, m_param_threshold(threshold)
109, m_param_print_cpu_time_resolution(print_cpu_time_resolution)
110, m_param_amg_coarsening_method(amg_coarsening_method)
111, m_param_output_level(output_level)
112, m_param_amg_cycle(amg_cycle)
113, m_param_amg_solver_iterations(amg_solver_iterations)
114, m_param_amg_smoother_iterations(amg_smoother_iterations)
115, m_param_amg_smootherOption(amg_smootherOption)
116, m_param_amg_coarseningOption(amg_coarseningOption)
117, m_param_amg_coarseSolverOption(amg_coarseSolverOption)
118, m_param_keep_solver_structure(keep_solver_structure)
119, m_param_sequential_solver(sequential_solver)
120, m_param_criteria_stop(param_criteria_stop)
121{
122 //debug() << "\33[1;4;33m\t[AlephParams] New"<<"\33[0m";
123}
124
125AlephParams::
126~AlephParams()
127{
128 //debug() << "\33[1;4;33m\t[~AlephParams]"<<"\33[0m";
129}
130
131// set
132void AlephParams::setEpsilon(const Real epsilon)
133{
134 m_param_epsilon = epsilon;
135}
136void AlephParams::setMaxIter(const Integer max_iteration)
137{
138 m_param_max_iteration = max_iteration;
139}
140void AlephParams::setPrecond(const TypesSolver::ePreconditionerMethod preconditioner_method)
141{
142 m_param_preconditioner_method = preconditioner_method;
143}
144void AlephParams::setMethod(const TypesSolver::eSolverMethod solver_method)
145{
146 m_param_solver_method = solver_method;
147}
148void AlephParams::setAlpha(const Real alpha)
149{
150 m_param_alpha = alpha;
151}
152void AlephParams::setGamma(const Integer gamma)
153{
154 m_param_gamma = gamma;
155}
156void AlephParams::setXoUser(const bool xo_user)
157{
158 m_param_xo_user = xo_user;
159}
160void AlephParams::setCheckRealResidue(const bool check_real_residue)
161{
162 m_param_check_real_residue = check_real_residue;
163}
164void AlephParams::setPrintRealResidue(const bool print_real_residue)
165{
166 m_param_print_real_residue = print_real_residue;
167}
168void AlephParams::setDebugInfo(const bool debug_info)
169{
170 m_param_debug_info = debug_info;
171}
172void AlephParams::setMinRHSNorm(const Real min_rhs_norm)
173{
174 m_param_min_rhs_norm = min_rhs_norm;
175}
176void AlephParams::setConvergenceAnalyse(const bool convergence_analyse)
177{
178 m_param_convergence_analyse = convergence_analyse;
179}
180void AlephParams::setStopErrorStrategy(const bool stop_error_strategy)
181{
182 m_param_stop_error_strategy = stop_error_strategy;
183}
184void AlephParams::setWriteMatrixToFileErrorStrategy(const bool write_matrix_to_file_error_strategy)
185{
186 m_param_write_matrix_to_file_error_strategy = write_matrix_to_file_error_strategy;
187}
188void AlephParams::setWriteMatrixNameErrorStrategy(const String& write_matrix_name_error_strategy)
189{
190 m_param_write_matrix_name_error_strategy = write_matrix_name_error_strategy;
191}
192void AlephParams::setDDMCParameterListingOutput(const bool listing_output)
193{
194 m_param_listing_output = listing_output;
195}
196void AlephParams::setDDMCParameterAmgDiagonalThreshold(const Real threshold)
197{
198 m_param_threshold = threshold;
199}
200void AlephParams::setPrintCpuTimeResolution(const bool print_cpu_time_resolution)
201{
202 m_param_print_cpu_time_resolution = print_cpu_time_resolution;
203}
204
205void AlephParams::
206setAmgCoarseningMethod(const TypesSolver::eAmgCoarseningMethod method)
207{
208 switch (method) {
209 case TypesSolver::AMG_COARSENING_AUTO:
210 m_param_amg_coarsening_method = 6;
211 break;
212 case TypesSolver::AMG_COARSENING_HYPRE_0:
213 m_param_amg_coarsening_method = 0;
214 break;
215 case TypesSolver::AMG_COARSENING_HYPRE_1:
216 m_param_amg_coarsening_method = 1;
217 break;
218 case TypesSolver::AMG_COARSENING_HYPRE_3:
219 m_param_amg_coarsening_method = 3;
220 break;
221 case TypesSolver::AMG_COARSENING_HYPRE_6:
222 m_param_amg_coarsening_method = 6;
223 break;
224 case TypesSolver::AMG_COARSENING_HYPRE_7:
225 m_param_amg_coarsening_method = 7;
226 break;
227 case TypesSolver::AMG_COARSENING_HYPRE_8:
228 m_param_amg_coarsening_method = 8;
229 break;
230 case TypesSolver::AMG_COARSENING_HYPRE_9:
231 m_param_amg_coarsening_method = 9;
232 break;
233 case TypesSolver::AMG_COARSENING_HYPRE_10:
234 m_param_amg_coarsening_method = 10;
235 break;
236 case TypesSolver::AMG_COARSENING_HYPRE_11:
237 m_param_amg_coarsening_method = 11;
238 break;
239 case TypesSolver::AMG_COARSENING_HYPRE_21:
240 m_param_amg_coarsening_method = 21;
241 break;
242 case TypesSolver::AMG_COARSENING_HYPRE_22:
243 m_param_amg_coarsening_method = 22;
244 break;
245 default:
246 throw NotImplementedException(A_FUNCINFO);
247 }
248}
249void AlephParams::setOutputLevel(const Integer output_level)
250{
251 m_param_output_level = output_level;
252}
253void AlephParams::setAmgCycle(const Integer amg_cycle)
254{
255 m_param_amg_cycle = amg_cycle;
256}
257void AlephParams::setAmgSolverIter(const Integer amg_solver_iterations)
258{
259 m_param_amg_solver_iterations = amg_solver_iterations;
260}
261void AlephParams::setAmgSmootherIter(const Integer amg_smoother_iterations)
262{
263 m_param_amg_smoother_iterations = amg_smoother_iterations;
264}
265void AlephParams::setAmgSmootherOption(const TypesSolver::eAmgSmootherOption amg_smootherOption)
266{
267 m_param_amg_smootherOption = amg_smootherOption;
268}
269void AlephParams::setAmgCoarseningOption(const TypesSolver::eAmgCoarseningOption amg_coarseningOption)
270{
271 m_param_amg_coarseningOption = amg_coarseningOption;
272}
273void AlephParams::setAmgCoarseSolverOption(const TypesSolver::eAmgCoarseSolverOption amg_coarseSolverOption)
274{
275 m_param_amg_coarseSolverOption = amg_coarseSolverOption;
276}
277void AlephParams::setKeepSolverStructure(const bool keep_solver_structure)
278{
279 m_param_keep_solver_structure = keep_solver_structure;
280}
281void AlephParams::setSequentialSolver(const bool sequential_solver)
282{
283 m_param_sequential_solver = sequential_solver;
284}
285void AlephParams::setCriteriaStop(const TypesSolver::eCriteriaStop criteria_stop)
286{
287 m_param_criteria_stop = criteria_stop;
288}
289
290// get
291Real AlephParams::epsilon() const
292{
293 return m_param_epsilon;
294}
295int AlephParams::maxIter() const
296{
297 return m_param_max_iteration;
298}
299Real AlephParams::alpha() const
300{
301 return m_param_alpha;
302}
303int AlephParams::gamma() const
304{
305 return m_param_gamma;
306}
307TypesSolver::ePreconditionerMethod AlephParams::precond()
308{
309 return m_param_preconditioner_method;
310}
311TypesSolver::eSolverMethod AlephParams::method()
312{
313 return m_param_solver_method;
314}
315bool AlephParams::xoUser() const
316{
317 return m_param_xo_user;
318}
319bool AlephParams::checkRealResidue() const
320{
321 return m_param_check_real_residue;
322}
323bool AlephParams::printRealResidue() const
324{
325 return m_param_print_real_residue;
326}
327bool AlephParams::debugInfo()
328{
329 return m_param_debug_info;
330}
331Real AlephParams::minRHSNorm()
332{
333 return m_param_min_rhs_norm;
334}
335bool AlephParams::convergenceAnalyse()
336{
337 return m_param_convergence_analyse;
338}
339bool AlephParams::stopErrorStrategy()
340{
341 return m_param_stop_error_strategy;
342}
343bool AlephParams::writeMatrixToFileErrorStrategy()
344{
345 return m_param_write_matrix_to_file_error_strategy;
346}
347String AlephParams::writeMatrixNameErrorStrategy()
348{
349 return m_param_write_matrix_name_error_strategy;
350}
351bool AlephParams::DDMCParameterListingOutput() const
352{
353 return m_param_listing_output;
354}
355Real AlephParams::DDMCParameterAmgDiagonalThreshold() const
356{
357 return m_param_threshold;
358}
359bool AlephParams::printCpuTimeResolution() const
360{
361 return m_param_print_cpu_time_resolution;
362}
363int AlephParams::amgCoarseningMethod() const
364{
365 return m_param_amg_coarsening_method;
366} // -1 for Sloop
367int AlephParams::getOutputLevel() const
368{
369 return m_param_output_level;
370}
371int AlephParams::getAmgCycle() const
372{
373 return m_param_amg_cycle;
374}
375int AlephParams::getAmgSolverIter() const
376{
377 return m_param_amg_solver_iterations;
378}
379int AlephParams::getAmgSmootherIter() const
380{
381 return m_param_amg_smoother_iterations;
382}
383TypesSolver::eAmgSmootherOption AlephParams::getAmgSmootherOption() const
384{
385 return m_param_amg_smootherOption;
386}
387TypesSolver::eAmgCoarseningOption AlephParams::getAmgCoarseningOption() const
388{
389 return m_param_amg_coarseningOption;
390}
391TypesSolver::eAmgCoarseSolverOption AlephParams::getAmgCoarseSolverOption() const
392{
393 return m_param_amg_coarseSolverOption;
394}
395bool AlephParams::getKeepSolverStructure() const
396{
397 return m_param_keep_solver_structure;
398}
399bool AlephParams::getSequentialSolver() const
400{
401 return m_param_sequential_solver;
402}
403TypesSolver::eCriteriaStop AlephParams::getCriteriaStop() const
404{
405 return m_param_criteria_stop;
406}
407
408/*---------------------------------------------------------------------------*/
409/*---------------------------------------------------------------------------*/
410
411} // namespace Arcane
412
413/*---------------------------------------------------------------------------*/
414/*---------------------------------------------------------------------------*/
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --