33 template<
typename Scalar>
35 matrixVarname(
"A"), matrixFormat(
Hermes::Algebra::
EXPORT_FORMAT_PLAIN_ASCII), matrix_number_format(
"%lf"), output_rhsOn(false), output_rhsIterations(-1),
40 template<
typename Scalar>
43 if (matrix ==
nullptr)
46 if (this->output_matrixOn)
48 char* fileName = malloc_with_check<char>(this->matrixFilename.length() + 5);
49 if (this->only_lastMatrixIteration)
50 sprintf(fileName,
"%s", this->matrixFilename.c_str());
51 else if (this->output_matrixIterations == -1 || this->output_matrixIterations >= iteration)
52 sprintf(fileName,
"%s_%i", this->matrixFilename.c_str(), iteration);
55 free_with_check(fileName);
59 matrix->
export_to_file(fileName, this->matrixVarname.c_str(), this->matrixFormat, this->matrix_number_format);
60 free_with_check(fileName);
64 template<
typename Scalar>
67 if (matrix ==
nullptr)
70 if (this->output_matrixOn)
72 char* fileName = malloc_with_check<char>(this->matrixFilename.length() + 5);
73 sprintf(fileName,
"%s", this->matrixFilename.c_str());
74 matrix->
export_to_file(fileName, this->matrixVarname.c_str(), this->matrixFormat, this->matrix_number_format);
75 free_with_check(fileName);
79 template<
typename Scalar>
85 if (this->output_rhsOn)
87 char* fileName = malloc_with_check<char>(this->RhsFilename.length() + 5);
88 if (this->only_lastRhsIteration)
89 sprintf(fileName,
"%s", this->RhsFilename.c_str());
90 else if (this->output_rhsIterations == -1 || this->output_rhsIterations >= iteration)
91 sprintf(fileName,
"%s_%i", this->RhsFilename.c_str(), iteration);
94 free_with_check(fileName);
98 rhs->
export_to_file(fileName, this->RhsVarname.c_str(), this->RhsFormat, this->rhs_number_format);
99 free_with_check(fileName);
103 template<
typename Scalar>
109 if (this->output_rhsOn)
111 char* fileName = malloc_with_check<char>(this->RhsFilename.length() + 5);
112 sprintf(fileName,
"%s", this->RhsFilename.c_str());
113 rhs->
export_to_file(fileName, this->RhsVarname.c_str(), this->RhsFormat, this->rhs_number_format);
114 free_with_check(fileName);
118 template<
typename Scalar>
121 output_matrixOn =
true;
122 this->only_lastMatrixIteration = only_last_iteration;
123 this->output_matrixIterations = firstIterations;
125 template<
typename Scalar>
128 this->matrixFilename = name;
131 template<
typename Scalar>
134 this->print_matrix_zero_values = to_set;
137 template<
typename Scalar>
140 this->matrixVarname = name;
142 template<
typename Scalar>
145 this->matrixFormat = format;
148 template<
typename Scalar>
151 this->matrix_number_format = number_format;
154 template<
typename Scalar>
157 this->output_rhsOn =
true;
158 this->only_lastRhsIteration = only_last_iteration;
159 this->output_rhsIterations = firstIterations;
161 template<
typename Scalar>
164 this->RhsFilename = name;
166 template<
typename Scalar>
169 this->RhsVarname = name;
171 template<
typename Scalar>
174 this->RhsFormat = format;
176 template<
typename Scalar>
179 this->rhs_number_format = number_format;
182 template<
typename Scalar>
185 this->export_to_file(filename.c_str(), var_name, fmt, number_format);
188 template<
typename Scalar>
191 this->export_to_file(filename.c_str(), var_name.c_str(), fmt, number_format);
194 template<
typename Scalar>
197 this->import_from_file(filename.c_str(), var_name, fmt);
200 template<
typename Scalar>
203 this->import_from_file(filename.c_str(), var_name.c_str(), fmt);
206 template HERMES_API
class MatrixRhsOutput < double > ;
207 template HERMES_API
class MatrixRhsOutput < std::complex<double> > ;
208 template HERMES_API
class MatrixRhsImportExport < double > ;
209 template HERMES_API
class MatrixRhsImportExport < std::complex<double> > ;
General namespace for the Hermes library.
General (abstract) vector representation in Hermes.
virtual void export_to_file(const char *filename, const char *var_name, Algebra::MatrixExportFormat fmt, char *number_format="%lf")=0
void output_rhs(bool only_last_iteration=true, int firstIterations=-1)
virtual void import_from_file(const char *filename, const char *var_name, Algebra::MatrixExportFormat fmt)
void set_matrix_varname(std::string name)
File containing common definitions, and basic global enums etc. for HermesCommon. ...
void set_matrix_export_format(Hermes::Algebra::MatrixExportFormat format)
void process_vector_output(Hermes::Algebra::Vector< Scalar > *rhs, int iteration)
Processes the matrix.
General (abstract) sparse matrix representation in Hermes.
MatrixExportFormat
Format of file matrix and vector output.
Plain ascii file lines contains row column and value.
void set_matrix_number_format(char *number_format)
void set_rhs_filename(std::string name)
Basic matrix classes and operations.
Mixins classes for algebraic purposes.
void set_rhs_varname(std::string name)
void set_print_zero_matrix_entries(bool to_set)
Sets this instance to output matrix entries even though they are zero or not.
Basic vector classes and operations.
void set_rhs_export_format(Hermes::Algebra::MatrixExportFormat format)
void process_matrix_output(Hermes::Algebra::SparseMatrix< Scalar > *matrix, int iteration)
Processes the matrix.
void output_matrix(bool only_last_iteration=true, int firstIterations=-1)
void set_rhs_number_format(char *number_format)
void set_matrix_filename(std::string name)