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

162{
163 auto opt_prefix = getEnvironmentVariable("OGS_GLOBAL_MAT_OUT_PREFIX");
164
165 if (opt_prefix.has_value())
166 {
167#ifndef USE_PETSC
168 do_output_ = true;
169 filenamePrefix_ = std::move(*opt_prefix);
170#else
171 // TODO implement. PETScMatrix's viewer() method could be used for that.
172 WARN(
173 "You requested global matrix output (OGS_GLOBAL_MAT_OUT_PREFIX is "
174 "set), which is not yet implemented for PETSc matrices.");
175#endif
176 }
177}
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()() [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 179 of file MatrixOutput.cpp.

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

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

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

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

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

◆ do_output_

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

Definition at line 40 of file MatrixOutput.h.

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

◆ filenamePrefix_

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

Definition at line 34 of file MatrixOutput.h.

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


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