-
Notifications
You must be signed in to change notification settings - Fork 17
Support EQDSK field #318
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
base: develop
Are you sure you want to change the base?
Support EQDSK field #318
Changes from all commits
5b643e7
9b4590b
bc8603b
bb5e0cd
0bb3676
8706380
0ba19c3
fa9292f
733547f
d6d8f2d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| #ifndef PCMS_EQDSK_FIELD_H | ||
| #define PCMS_EQDSK_FIELD_H | ||
|
|
||
| #include "pcms/utility/eqdsk.h" | ||
| #include "pcms/field/layout/uniform_grid.h" | ||
| #include "pcms/field/function_space/spline.h" | ||
|
|
||
| #include <string> | ||
|
|
||
| namespace pcms | ||
| { | ||
|
|
||
| struct EQDSKField | ||
| { | ||
| SplineFunctionSpace space; | ||
| Field<Real> field; | ||
| }; | ||
|
|
||
| // TODD: @jacobmerson replace with Function. | ||
| struct EQDSKFieldWithData | ||
|
Sichao25 marked this conversation as resolved.
|
||
| { | ||
| EQDSKData data; | ||
| SplineFunctionSpace space; | ||
| Field<Real> field; | ||
| }; | ||
|
|
||
| /** | ||
| * @brief Create a SplineFunctionSpace and Field from EQDSKData, combining | ||
| * function space creation, field allocation, and DOF holder data population | ||
| * into a single call. | ||
| * | ||
| * Performs three steps: | ||
| * 1. Creates a SplineFunctionSpace from the EQDSK data | ||
| * 2. Creates a Field<Real> on that function space | ||
| * 3. Populates the field's DOF holder with the PSIZR flux data | ||
| * | ||
| * @param eqdsk_data The EQDSK equilibrium data containing the grid and flux | ||
| * values. | ||
| * @return EQDSKField A struct containing the function space and populated | ||
| * field, ready for evaluation. | ||
| */ | ||
| inline EQDSKField MakeEQDSKField(const EQDSKData& eqdsk_data) | ||
| { | ||
| auto space = SplineFunctionSpace::FromUniformGrid( | ||
| eqdsk_data.grid, CoordinateSystem::Cartesian); | ||
| auto field = space.CreateField<Real>(); | ||
| field.GetData().SetDOFHolderData(Rank1View<const Real, DeviceMemorySpace>( | ||
| eqdsk_data.PSIZR.data(), eqdsk_data.PSIZR.extent(0))); | ||
| return {std::move(space), std::move(field)}; | ||
| } | ||
|
|
||
| /** | ||
| * @brief Read an EQDSK file and construct a SplineFunctionSpace and Field from | ||
| * it, combining file I/O, function space creation, field allocation, and DOF | ||
| * holder data population into a single call. | ||
| * | ||
| * Performs four steps: | ||
| * 1. Reads the EQDSK file into an EQDSKData | ||
| * 2. Creates a SplineFunctionSpace from the data | ||
| * 3. Creates a Field<Real> on that function space | ||
| * 4. Populates the field's DOF holder with the PSIZR flux data | ||
| * | ||
| * @param filename Path to the EQDSK equilibrium file. | ||
| * @return EQDSKFieldWithData A struct containing the data, function space, | ||
| * and populated field, ready for evaluation. | ||
| */ | ||
| inline EQDSKFieldWithData MakeEQDSKField(const std::string& filename) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @usmanriaz07 Are there potentially other fields in the EQDSK that may need to be evaluated later, or is the only field we evaluated in the eqdsk the psi field? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We do use poloidal current value in the field line tracing. See the following piece of code: In ezfit.F90, the relevant function is: https://github.com/SCOREC/STOMMS/blob/main/stomms_meshgen/src/ezfit.F90#L562-L578 Other than poloidal current, we only need psi field.
Sichao25 marked this conversation as resolved.
|
||
| { | ||
| auto eqdsk_data = EQDSKData(filename); | ||
| auto [space, field] = MakeEQDSKField(eqdsk_data); | ||
| return {std::move(eqdsk_data), std::move(space), std::move(field)}; | ||
| } | ||
|
|
||
| } // namespace pcms | ||
|
|
||
| #endif // PCMS_EQDSK_FIELD_H | ||
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.
Is there ever a time where we would have an eqdsk with no data associated with it?
Uh oh!
There was an error while loading. Please reload this page.
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.
There will always be an
EQDSKData, but it doesn't have to be created with the helper functions defined here. It can be constructed manually instead of loaded directly from a file. The struct defined here is just for return values.