Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TecPlot utility #2114

Merged
merged 4 commits into from
Apr 25, 2018
Merged

TecPlot utility #2114

merged 4 commits into from
Apr 25, 2018

Conversation

rinkk
Copy link
Member

@rinkk rinkk commented Apr 20, 2018

Currently can

  • split TecPlot files containing multiple "zones" (i.e. timesteps, subdomains, etc.) into seperate tecplot files
  • convert TecPlot files representing raster data into ogs-meshes (one file per zone, containing all variables as scalar arrays)

std::pair<std::size_t, std::size_t> dims(0,0);
std::size_t val_count(0), val_total(0);
std::size_t write_count(0);
while (getline(in, line))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

std::getline?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✔️

/// Splits a TecPlot file containing multiple sections/zones into seperate files
int splitFile(std::ifstream& in, std::string file_name)
{
std::ofstream out;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is out initialized? What is the purpose of out?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

out is initalised / switched to the next file / closed in writeTecPlotSection()

{
std::ofstream out;
std::string line("");
std::string name;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The created name object is empty. It is used, for instance, in line 245 and 252, but will be initialized in line 262. Could this be a problem?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed all instances ("")

std::ofstream out;
std::string line("");
std::string name;
std::pair<std::size_t, std::size_t> dims(0,0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dims could be more local, it is used as a temporary variabele while parsing the zone.

val_count++;
}
if (dataCountError(out, name, val_count, val_total))
return -3;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why -3? It seems the method could return a bool value.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Different values indicate different reasons for failing. -3 is indicating an index error.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd recommend to document the magic numbers.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I put an explanation on the exit codes in the documentation. Independent of that, a detailed error-message is output in each case.

std::size_t const n_scalars (scalars.size());
while (iss >> x)
{
if (i > n_scalars-1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible that n_scalars is zero at this point? I'm not sure, but n_scalars - 1 is probably very large. Is this okay?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Barring an invalid TecPlot-file, n_scalars must be larger than 0, otherwise the zone-section would contain no data.

Copy link
Member

@endJunction endJunction left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comment on documentation.
If you would run clang-format on the changes before merging, it would be nice.

Copy link
Member

@TomFischer TomFischer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@endJunction endJunction merged commit 1ce838b into ufz:master Apr 25, 2018
@rinkk rinkk deleted the TecPlotTools2 branch April 12, 2019 15:30
@ogsbot
Copy link
Member

ogsbot commented Jun 19, 2020

OpenGeoSys development has been moved to GitLab.

See this pull request on GitLab.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants