OGS
ProcessLib::Assembly::GlobalMatrixOutput Struct Reference

Detailed Description

Writes global matrices to disk for debugging purposes.

Definition at line 16 of file MatrixOutput.h.

#include <MatrixOutput.h>

Public Member Functions

 GlobalMatrixOutput ()
void operator() (double const t, int const process_id, GlobalMatrix const &M, GlobalMatrix const &K, GlobalVector const &b)
void operator() (double const t, int const process_id, GlobalVector const &b, GlobalMatrix const &Jac)

Private Attributes

std::string filenamePrefix_
std::size_t counter_ = 0
bool do_output_ = false

Constructor & Destructor Documentation

◆ GlobalMatrixOutput()

ProcessLib::Assembly::GlobalMatrixOutput::GlobalMatrixOutput ( )

Definition at line 154 of file MatrixOutput.cpp.

155{
156 auto opt_prefix = getEnvironmentVariable("OGS_GLOBAL_MAT_OUT_PREFIX");
157
158 if (opt_prefix.has_value())
159 {
160#ifndef USE_PETSC
161 do_output_ = true;
162 filenamePrefix_ = std::move(*opt_prefix);
163#else
164 // TODO implement. PETScMatrix's viewer() method could be used for that.
165 WARN(
166 "You requested global matrix output (OGS_GLOBAL_MAT_OUT_PREFIX is "
167 "set), which is not yet implemented for PETSc matrices.");
168#endif
169 }
170}
void WARN(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:34
static std::optional< std::string > getEnvironmentVariable(std::string const &env_var)

References do_output_, filenamePrefix_, and WARN().

Member Function Documentation

◆ operator()() [1/2]

void ProcessLib::Assembly::GlobalMatrixOutput::operator() ( double const t,
int const process_id,
GlobalMatrix const & M,
GlobalMatrix const & K,
GlobalVector const & b )

Definition at line 172 of file MatrixOutput.cpp.

176{
177 if (!do_output_)
178 {
179 return;
180 }
181
182#ifndef USE_PETSC
183 ++counter_;
184
185 {
186 auto fh = openGlobalMatrixOutputFile(filenamePrefix_, counter_, t,
187 process_id, "M", "mat");
188
189 fh << "M ";
190 outputGlobalMatrix(M, fh);
191 }
192
193 {
194 auto fh = openGlobalMatrixOutputFile(filenamePrefix_, counter_, t,
195 process_id, "K", "mat");
196
197 fh << "K ";
198 outputGlobalMatrix(K, fh);
199 }
200
201 {
202 auto fh = openGlobalMatrixOutputFile(filenamePrefix_, counter_, t,
203 process_id, "b", "vec");
204
205 fh << "b ";
206 outputGlobalVector(b, fh);
207 }
208#else
209 // do nothing, warning message already printed in the constructor
210 (void)t;
211 (void)process_id;
212 (void)M;
213 (void)K;
214 (void)b;
215#endif
216}

References counter_, do_output_, and filenamePrefix_.

◆ operator()() [2/2]

void ProcessLib::Assembly::GlobalMatrixOutput::operator() ( double const t,
int const process_id,
GlobalVector const & b,
GlobalMatrix const & Jac )

Definition at line 218 of file MatrixOutput.cpp.

221{
222 if (!do_output_)
223 {
224 return;
225 }
226
227#ifndef USE_PETSC
228 ++counter_;
229
230 {
231 auto fh = openGlobalMatrixOutputFile(filenamePrefix_, counter_, t,
232 process_id, "b", "vec");
233
234 fh << "b ";
235 outputGlobalVector(b, fh);
236 }
237
238 {
239 auto fh = openGlobalMatrixOutputFile(filenamePrefix_, counter_, t,
240 process_id, "Jac", "mat");
241
242 fh << "Jac ";
243 outputGlobalMatrix(Jac, fh);
244 }
245#else
246 // do nothing, warning message already printed in the constructor
247 (void)t;
248 (void)process_id;
249 (void)b;
250 (void)Jac;
251#endif
252}

References counter_, do_output_, and filenamePrefix_.

Member Data Documentation

◆ counter_

std::size_t ProcessLib::Assembly::GlobalMatrixOutput::counter_ = 0
private

Used to distinguish output files of global matrices at the same time, but, e.g., at different non-linear iterations etc.

Definition at line 31 of file MatrixOutput.h.

Referenced by operator()(), and operator()().

◆ do_output_

bool ProcessLib::Assembly::GlobalMatrixOutput::do_output_ = false
private

Definition at line 33 of file MatrixOutput.h.

Referenced by GlobalMatrixOutput(), operator()(), and operator()().

◆ filenamePrefix_

std::string ProcessLib::Assembly::GlobalMatrixOutput::filenamePrefix_
private

Definition at line 27 of file MatrixOutput.h.

Referenced by GlobalMatrixOutput(), operator()(), and operator()().


The documentation for this struct was generated from the following files: