-
Notifications
You must be signed in to change notification settings - Fork 37
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
custom coords #1039
custom coords #1039
Conversation
@@ -3,11 +3,11 @@ | |||
## Current develop | |||
|
|||
### Added (new features/APIs/variables/...) | |||
|
|||
- [[PR1039]](https://github.com/parthenon-hpc-lab/parthenon/pull/1039) Add ability to output custom coordinate positions for Visit/Paraview |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this ended up in the changelog for the previous release by accident.
@@ -184,6 +184,88 @@ std::ostream &operator<<(std::ostream &os, const parthenon::Metadata &m) { | |||
return os; | |||
} | |||
|
|||
// Return true if the flags constraints are satisfied, false otherwise. If throw_on_fail | |||
// is true, throw a descriptive exception when invalid | |||
bool Metadata::IsValid(bool throw_on_fail) const { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved from hpp to cpp
src/outputs/parthenon_xdmf.cpp
Outdated
const int n3_offset = output_coords ? (nx3 > 1) : 1; | ||
const int n2_offset = output_coords ? (nx2 > 1) : 1; | ||
int ndim_mesh; | ||
std::string mesh_type, dimstring; | ||
if (output_coords) { | ||
if (nx3 > 1) { | ||
ndim_mesh = 3; | ||
mesh_type = "3DSMesh"; | ||
dimstring = StringPrintf("%d %d %d", nx3 + n3_offset, nx2 + n2_offset, nx1 + 1); | ||
} else if (nx2 > 1) { | ||
ndim_mesh == 2; | ||
mesh_type = "2DSMesh"; | ||
dimstring = StringPrintf("%d %d", nx2 + n2_offset, nx1 + 1); | ||
} else { | ||
ndim_mesh == 1; | ||
mesh_type = "Polyline"; | ||
dimstring = StringPrintf("%d", nx1 + 1); | ||
} | ||
} else { | ||
mesh_type = "3DRectMesh"; | ||
ndim_mesh = 3; | ||
dimstring = StringPrintf("%d %d %d", nx3 + n3_offset, nx2 + n2_offset, nx1 + 1); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This madness merits explanation. The story goes like this:
- We want Visit/Paraview to use output mesh data (rather than the
x*f
arrays) as coordinates. This means going toSMesh
in 3D and 2D. - Paraview/Visit expects coordinate positions to be at nodes. We always output 1 extra face even in trivial directions for the
x*f
arrays. But we don't for positions of node-centered fields. This necessitates changing the dimension of the data that is read by visit/paraview depedning on output dimension. In other words, in 2D we must use2DSMesh
, not3DSMesh
and it needs an(nx2+1, nx1+1)
array, not a(1, nx2+1, nx1+1)
array. - 1D gets crazier as there is no structured mesh object in 1D in
xdmf
. OnlyPolyline
.
The remaining changes to this file can be understood as contorting themselves to support the above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok I am dropping the 1D as it's a lot of contortion for an uncommon use-case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, will be great to finally be able to use xdmf outputs for something in KHARMA
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but I am not sure that I can provide too useful of a review of the xdmf. The fact that it works is good enough for me though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some last minute post-merge comments for potential future clarification.
Thanks @pgrete I'll make these changes and submit a tirival PR to fix |
PR Summary
This PR is designed to support codes like
Phoebus
,Artemis
, andAssail
downstream that uses coordinates that are not the uniform cartesian coordinate system. It lets you tag a mesh variable as a coordinates array. To do say, make your variable a node-centered 3-vector and add theMetadata::CoordinatesVec
MetadataFlag
to it. Then fill this variable with thex
,y
, andz
coordinates of your nodes as appropriate.If you do this, the variable will automatically be output in dumps and restarts and the xdmf file will will record this field as your coordinates per meshblock. Tested in
parthenon-mhd
.This is also ready for downstream testing and review in downstream codes. Depends on #1019 . I haven't fully cleaned up formatting/linting/docs yet.
PR Checklist