Skip to content

Commit

Permalink
added module for WriteToFile: only write filter output every 10th ite…
Browse files Browse the repository at this point in the history
…ration
  • Loading branch information
jomichaelis committed Nov 6, 2024
1 parent 36ec067 commit 8e4f0ec
Showing 1 changed file with 30 additions and 26 deletions.
56 changes: 30 additions & 26 deletions coupling/filtering/filters/WriteToFile.cpph
Original file line number Diff line number Diff line change
Expand Up @@ -12,38 +12,42 @@ template <unsigned int dim> void coupling::filtering::WriteToFile<dim>::operator
std::cout << " WTF: Now writing data to: " << _location;
#endif

if (!_overwrite)
_file.open(_location, std::ios_base::app);
else {
_file.open(_location);
}
if (_iteration % 10 == 0) {

for (unsigned int ic_index = 0; ic_index < coupling::filtering::FilterInterface<dim>::_inputCells.size(); ic_index++) {
// case: only one cell
if (_oneCellOnly != -1)
ic_index = (unsigned int)_oneCellOnly;
if (!_overwrite)
_file.open(_location, std::ios_base::app);
else {
_file.open(_location);
}

_file << _iteration << " ; ";
for (unsigned int ic_index = 0; ic_index < coupling::filtering::FilterInterface<dim>::_inputCells.size(); ic_index++) {
// case: only one cell
if (_oneCellOnly != -1)
ic_index = (unsigned int)_oneCellOnly;

// printing all scalar values
for (const auto scalarProperty : coupling::filtering::FilterInterface<dim>::_scalarAccessFunctionPairs)
_file << (coupling::filtering::FilterInterface<dim>::_inputCells[ic_index]->*scalarProperty.get)() << " ; ";
_file << _iteration << " ; ";

// printing all vectorized values
for (const auto vectorProperty : coupling::filtering::FilterInterface<dim>::_vectorAccessFunctionPairs)
for (unsigned int d = 0; d < dim; d++)
_file << (coupling::filtering::FilterInterface<dim>::_inputCells[ic_index]->*vectorProperty.get)()[d] << " ; ";
// printing all scalar values
for (const auto scalarProperty : coupling::filtering::FilterInterface<dim>::_scalarAccessFunctionPairs)
_file << (coupling::filtering::FilterInterface<dim>::_inputCells[ic_index]->*scalarProperty.get)() << " ; ";

// case: only one cell
if (_oneCellOnly != -1)
break;
else
_file << std::endl; // spatial distinction between iteration in output
// file. Unneccesary if OCO.
}
// printing all vectorized values
for (const auto vectorProperty : coupling::filtering::FilterInterface<dim>::_vectorAccessFunctionPairs)
for (unsigned int d = 0; d < dim; d++)
_file << (coupling::filtering::FilterInterface<dim>::_inputCells[ic_index]->*vectorProperty.get)()[d] << " ; ";

// case: only one cell
if (_oneCellOnly != -1)
break;
else
_file << std::endl; // spatial distinction between iteration in output
// file. Unneccesary if OCO.
}

_file << std::endl;
_file.close();
_file << std::endl;
_file.close();

}

coupling::filtering::FilterInterfaceReadOnly<dim>::copyInputToOutput();

Expand Down

0 comments on commit 8e4f0ec

Please sign in to comment.