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
15void setCombineModeParameter(Teuchos::ParameterList& plist,
16 const std::string& paramName) {
18 typedef Teuchos::StringToIntegralParameterEntryValidator<enum_type>
20
21 const std::string docString =
22 "Tpetra::CombineMode: rule for combining "
23 "entries that overlap across processes, when redistributing data via a "
24 "Tpetra::Import or Tpetra::Export";
25 const std::string defaultVal = "ADD";
26 const bool caseSensitive = false;
27
28 const Teuchos::Array<std::string>::size_type numParams = 6;
29 Teuchos::Array<std::string> strs(numParams);
30 Teuchos::Array<std::string> docs(numParams);
31 Teuchos::Array<enum_type> vals(numParams);
32
33 strs[0] = "ADD";
34 strs[1] = "INSERT";
35 strs[2] = "REPLACE";
36 strs[3] = "ABSMAX";
37 strs[4] = "ZERO";
38 strs[5] = "ADD_ASSIGN";
39
40 docs[0] = "Sum new values";
41 docs[1] = "Insert new values that don't currently exist";
42 docs[2] = "Replace existing values with new values";
43 docs[3] = "Replace old value with maximum of magnitudes of old and new values";
44 docs[4] = "Replace old values with zero";
45 docs[5] =
46 "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
57 Teuchos::rcp(new validator_type(strs(), docs(), vals(),
59}
60
62 std::string combineModeStr;
63 switch (combineMode) {
64 case ADD:
65 combineModeStr = "ADD";
66 break;
67 case REPLACE:
68 combineModeStr = "REPLACE";
69 break;
70 case ABSMAX:
71 combineModeStr = "ABSMAX";
72 break;
73 case INSERT:
74 combineModeStr = "INSERT";
75 break;
76 case ZERO:
77 combineModeStr = "ZERO";
78 break;
79 case ADD_ASSIGN:
80 combineModeStr = "ADD_ASSIGN";
81 break;
82 default:
83 combineModeStr = "INVALID";
84 }
85 return combineModeStr;
86}
87
88} // namespace Tpetra
Declaration of Tpetra::CombineMode enum, and a function for setting a Tpetra::CombineMode parameter i...
Struct that holds views of the contents of a CrsMatrix.
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.