Tpetra parallel linear algebra Version of the Day
Loading...
Searching...
No Matches
Tpetra_CombineMode.cpp
1// @HEADER
2// *****************************************************************************
3// Tpetra: Templated Linear Algebra Services Package
4//
5// Copyright 2008 NTESS and the Tpetra contributors.
6// SPDX-License-Identifier: BSD-3-Clause
7// *****************************************************************************
8// @HEADER
9
11#include <Teuchos_StandardParameterEntryValidators.hpp>
12
13namespace Tpetra {
14
15 void
16 setCombineModeParameter (Teuchos::ParameterList& plist,
17 const std::string& paramName)
18 {
19 typedef Tpetra::CombineMode enum_type;
20 typedef Teuchos::StringToIntegralParameterEntryValidator<enum_type>
21 validator_type;
22
23 const std::string docString = "Tpetra::CombineMode: rule for combining "
24 "entries that overlap across processes, when redistributing data via a "
25 "Tpetra::Import or Tpetra::Export";
26 const std::string defaultVal = "ADD";
27 const bool caseSensitive = false;
28
29 const Teuchos::Array<std::string>::size_type numParams = 6;
30 Teuchos::Array<std::string> strs (numParams);
31 Teuchos::Array<std::string> docs (numParams);
32 Teuchos::Array<enum_type> vals (numParams);
33
34 strs[0] = "ADD";
35 strs[1] = "INSERT";
36 strs[2] = "REPLACE";
37 strs[3] = "ABSMAX";
38 strs[4] = "ZERO";
39 strs[5] = "ADD_ASSIGN";
40
41 docs[0] = "Sum new values";
42 docs[1] = "Insert new values that don't currently exist";
43 docs[2] = "Replace existing values with new values";
44 docs[3] = "Replace old value with maximum of magnitudes of old and new values";
45 docs[4] = "Replace old values with zero";
46 docs[5] = "Do addition assignment (+=) of new values into existing value; "
47 "may not be supported by all classes";
48
49 vals[0] = ADD;
50 vals[1] = INSERT;
51 vals[2] = REPLACE;
52 vals[3] = ABSMAX;
53 vals[4] = ZERO;
54 vals[5] = ADD_ASSIGN;
55
56 plist.set (paramName, defaultVal, docString,
57 Teuchos::rcp (new validator_type (strs (), docs (), vals (),
58 defaultVal, caseSensitive)));
59 }
60
61 std::string combineModeToString (const CombineMode combineMode)
62 {
63 std::string combineModeStr;
64 switch (combineMode) {
65 case ADD:
66 combineModeStr = "ADD";
67 break;
68 case REPLACE:
69 combineModeStr = "REPLACE";
70 break;
71 case ABSMAX:
72 combineModeStr = "ABSMAX";
73 break;
74 case INSERT:
75 combineModeStr = "INSERT";
76 break;
77 case ZERO:
78 combineModeStr = "ZERO";
79 break;
80 case ADD_ASSIGN:
81 combineModeStr = "ADD_ASSIGN";
82 break;
83 default:
84 combineModeStr = "INVALID";
85 }
86 return combineModeStr;
87 }
88
89} // namespace Tpetra
Declaration of Tpetra::CombineMode enum, and a function for setting a Tpetra::CombineMode parameter i...
Namespace Tpetra contains the class and methods constituting the Tpetra library.
std::string combineModeToString(const CombineMode combineMode)
Human-readable string representation of the given CombineMode.
void setCombineModeParameter(Teuchos::ParameterList &plist, const std::string &paramName)
Set CombineMode parameter in a Teuchos::ParameterList.
CombineMode
Rule for combining data in an Import or Export.
@ REPLACE
Replace existing values with new values.
@ ADD
Sum new values.
@ ABSMAX
Replace old value with maximum of magnitudes of old and new values.
@ ADD_ASSIGN
Accumulate new values into existing values (may not be supported in all classes).
@ INSERT
Insert new values that don't currently exist.
@ ZERO
Replace old values with zero.