OGS
ProcessLib::Assembly::detail Namespace Reference

Functions

GlobalIndexType transformToNonGhostIndex (GlobalIndexType const i, GlobalIndexType const n)
std::unordered_set< std::size_t > parseSetOfSizeT (std::string const &str, std::string const &warn_msg)
std::function< bool(std::size_t)> createLocalMatrixOutputElementPredicate (std::string const &element_ids_str)

Function Documentation

◆ createLocalMatrixOutputElementPredicate()

std::function< bool(std::size_t)> ProcessLib::Assembly::detail::createLocalMatrixOutputElementPredicate ( std::string const & element_ids_str)

Definition at line 126 of file MatrixOutput.cpp.

128{
129 if (element_ids_str.empty())
130 {
131 return {};
132 }
133
134 if (element_ids_str == "*")
135 {
136 return [](std::size_t) { return true; };
137 }
138
139 auto element_ids = parseSetOfSizeT(
140 element_ids_str,
141 "Error parsing list of element ids for local matrix debug "
142 "output. We'll try to proceed anyway, as best as we can.");
143
144 if (element_ids.empty())
145 {
146 return {};
147 }
148
149 return [element_ids = std::move(element_ids)](std::size_t element_id)
150 { return element_ids.contains(element_id); };
151}
std::unordered_set< std::size_t > parseSetOfSizeT(std::string const &str, std::string const &warn_msg)

References parseSetOfSizeT().

Referenced by ProcessLib::Assembly::LocalMatrixOutput::LocalMatrixOutput().

◆ parseSetOfSizeT()

std::unordered_set< std::size_t > ProcessLib::Assembly::detail::parseSetOfSizeT ( std::string const & str,
std::string const & warn_msg )

Definition at line 93 of file MatrixOutput.cpp.

95{
96 std::istringstream sstr{str};
97 std::unordered_set<std::size_t> result;
98 std::ptrdiff_t value;
99
100 while (sstr >> value)
101 {
102 [[likely]] if (value >= 0)
103 {
104 result.insert(value);
105 }
106 else
107 {
108 if (!warn_msg.empty())
109 {
110 WARN("{}", warn_msg);
111 }
112
113 return result;
114 }
115 }
116
117 if (!sstr.eof() && !warn_msg.empty()) // The stream is not read until
118 // the end, must be an error.
119 {
120 WARN("{}", warn_msg);
121 }
122
123 return result;
124}
void WARN(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:34

References WARN().

Referenced by createLocalMatrixOutputElementPredicate().

◆ transformToNonGhostIndex()

GlobalIndexType ProcessLib::Assembly::detail::transformToNonGhostIndex ( GlobalIndexType const i,
GlobalIndexType const n )
inline

Definition at line 22 of file MatrixElementCache.h.

24{
25 if (i == -n)
26 {
27 return 0;
28 }
29 else
30 {
31 return std::abs(i);
32 }
33}

Referenced by ProcessLib::Assembly::MatrixElementCache< Dim >::addCacheToGlobal().