Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
IMultiReduce.h
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/* IMultiReduce.h (C) 2000-2016 */
9/* */
10/* Management of multiple reductions. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_PARALLEL_IMULTIREDUCE_H
13#define ARCANE_PARALLEL_IMULTIREDUCE_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/utils/Array.h"
18
19/*---------------------------------------------------------------------------*/
20/*---------------------------------------------------------------------------*/
21
22namespace Arcane
23{
24
25/*---------------------------------------------------------------------------*/
26/*---------------------------------------------------------------------------*/
27
37class ARCANE_CORE_EXPORT ReduceSumOfRealHelper
38{
39 public:
40
41 ReduceSumOfRealHelper(bool is_strict)
42 : m_reduced_value(0.0)
43 , m_is_strict(is_strict)
44 {
45 if (!m_is_strict)
46 m_values.add(0.0);
47 }
48
49 public:
50
52 void add(Real v)
53 {
54 if (m_is_strict)
55 m_values.add(v);
56 else
57 m_values[0] += v;
58 }
59
61 void clear()
62 {
63 m_values.clear();
64 }
65
67 RealConstArrayView values() const { return m_values; }
68
70 Real reducedValue() const { return m_reduced_value; }
71
73 void setReducedValue(Real v) { m_reduced_value = v; }
74
75 private:
76
77 SharedArray<Real> m_values;
78 Real m_reduced_value;
79 bool m_is_strict;
80};
81
82/*---------------------------------------------------------------------------*/
83/*---------------------------------------------------------------------------*/
84
101class ARCANE_CORE_EXPORT IMultiReduce
102{
103 public:
104
105 virtual ~IMultiReduce() {}
106
107 public:
108
109 static IMultiReduce* create(IParallelMng* pm);
110
111 public:
112
114 virtual void execute() = 0;
115
117 virtual bool isStrict() const = 0;
118
120 virtual void setStrict(bool is_strict) = 0;
121
122 public:
123
131 virtual ReduceSumOfRealHelper* getSumOfReal(const String& name) = 0;
132};
133
134/*---------------------------------------------------------------------------*/
135/*---------------------------------------------------------------------------*/
136
137} // namespace Arcane
138
139/*---------------------------------------------------------------------------*/
140/*---------------------------------------------------------------------------*/
141
142#endif
Management of multiple reductions.
virtual void setStrict(bool is_strict)=0
Sets the strict mode.
virtual ReduceSumOfRealHelper * getSumOfReal(const String &name)=0
Returns the name manager name. If a name manager name does not exist, it is created....
virtual bool isStrict() const =0
Indicates if strict mode is used.
virtual ~IMultiReduce()
Frees resources.
virtual void execute()=0
Executes the reductions.
Interface of the parallelism manager for a subdomain.
Class managing a reduction of a sum of values.
RealConstArrayView values() const
List of accumulated values.
Real reducedValue() const
Reduced value.
void setReducedValue(Real v)
Positions the reduced value.
void add(Real v)
Adds the value v.
void clear()
Clears the accumulated values.
1D vector of data with reference semantics.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
double Real
Type representing a real number.
ConstArrayView< Real > RealConstArrayView
C equivalent of a 1D array of reals.
Definition UtilsTypes.h:488