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 133 of file MatrixOutput.cpp.

135{
136 if (element_ids_str.empty())
137 {
138 return {};
139 }
140
141 if (element_ids_str == "*")
142 {
143 return [](std::size_t) { return true; };
144 }
145
146 auto element_ids = parseSetOfSizeT(
147 element_ids_str,
148 "Error parsing list of element ids for local matrix debug "
149 "output. We'll try to proceed anyway, as best as we can.");
150
151 if (element_ids.empty())
152 {
153 return {};
154 }
155
156 return [element_ids = std::move(element_ids)](std::size_t element_id)
157 { return element_ids.contains(element_id); };
158}
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 100 of file MatrixOutput.cpp.

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

References WARN().

Referenced by createLocalMatrixOutputElementPredicate().

◆ transformToNonGhostIndex()

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

Definition at line 24 of file MatrixElementCache.h.

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

Referenced by ProcessLib::Assembly::ConcurrentMatrixView< Dim >::add().