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

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

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