OGS
ProcessLib::Assembly::GlobalMatrixOutput Struct Reference

Detailed Description

Writes global matrices to disk for debugging purposes.

Definition at line 23 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, GlobalMatrix const *const Jac=nullptr)
 

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

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

References do_output_, filenamePrefix_, and WARN().

Member Function Documentation

◆ operator()()

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

Definition at line 177 of file MatrixOutput.cpp.

182{
183 if (!do_output_)
184 {
185 return;
186 }
187
188#ifndef USE_PETSC
189 ++counter_;
190
191 {
192 auto fh = openGlobalMatrixOutputFile(filenamePrefix_, counter_, t,
193 process_id, "M", "mat");
194
195 fh << "M ";
196 outputGlobalMatrix(M, fh);
197 }
198
199 {
200 auto fh = openGlobalMatrixOutputFile(filenamePrefix_, counter_, t,
201 process_id, "K", "mat");
202
203 fh << "K ";
204 outputGlobalMatrix(K, fh);
205 }
206
207 {
208 auto fh = openGlobalMatrixOutputFile(filenamePrefix_, counter_, t,
209 process_id, "b", "vec");
210
211 fh << "b ";
212 outputGlobalVector(b, fh);
213 }
214
215 if (Jac)
216 {
217 auto fh = openGlobalMatrixOutputFile(filenamePrefix_, counter_, t,
218 process_id, "Jac", "mat");
219
220 fh << "Jac ";
221 outputGlobalMatrix(*Jac, fh);
222 }
223#else
224 // do nothing, warning message already printed in the constructor
225 (void)t;
226 (void)process_id;
227 (void)M;
228 (void)K;
229 (void)b;
230 (void)Jac;
231#endif
232}

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 36 of file MatrixOutput.h.

Referenced by operator()().

◆ do_output_

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

Definition at line 38 of file MatrixOutput.h.

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

◆ filenamePrefix_

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

Definition at line 32 of file MatrixOutput.h.

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


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