-
Notifications
You must be signed in to change notification settings - Fork 19
Issue 878 CG ice velocity components #879
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
Open
timspainNERSC
wants to merge
14
commits into
develop
Choose a base branch
from
issue878_cguv
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
b230a73
Handle different ModelArray types in CGDynamicsKernel::ma2cg.
timspainNERSC 3a88d27
Add the getCGData function.
timspainNERSC d309245
Use getCGData to retrieve full CG ice velocity components.
timspainNERSC 8ad8702
Remove commented out code.
timspainNERSC 21049d0
clang formatting
timspainNERSC 4262ce6
Interpolate from DG0 to CG, if necessary.
timspainNERSC 97a2a89
Read CG ice velocity data. Set the CG dimensions from the dynamics.
timspainNERSC 90eb8de
Use the correct length ofr dimensions (to get CG dimensions to work).
timspainNERSC c168d80
Correct dimension names for CG fields.
timspainNERSC 0cd2868
clang formatting
timspainNERSC 6d846b8
Remove the U ModelArray type.
timspainNERSC ca3dddb
Merge remote-tracking branch 'origin/develop' into issue878_cguv
einola 5862887
Merge branch 'develop' into issue878_cguv
TomMelt 7fb04dd
Merge branch 'develop' into issue878_cguv
TomMelt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -103,6 +103,27 @@ void BBMDynamics::setData(const ModelState::DataMap& ms) | |
| uice = ms.at(uName); | ||
| vice = ms.at(vName); | ||
|
|
||
| // Handle CG data field sizes | ||
| const ModelArray::MultiDim cgDims = kernel.getCGDimensions(); | ||
| /* If the u is Type::CG and the dimensions read from the restart file do | ||
| * not match those of the CG dynamics kernel, throw an exception. | ||
| * TODO: Support interpolation between different CG number of Gauss points. | ||
|
Contributor
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. Is this TODO for this PR or for a future one? |
||
| */ | ||
| if (uice.getType() == ModelArray::Type::CG && uice.dimensions()[0] != cgDims[0]) { | ||
| // CG degree of the read data | ||
| const unsigned int fileCGdegree = (ModelArray::dimensions(ModelArray::Type::CG)[0] - 1) | ||
| / ModelArray::dimensions(ModelArray::Type::H)[0]; | ||
| const unsigned int modelCGdegree = (cgDims[0] - 1) | ||
| / ModelArray::dimensions(ModelArray::Type::H)[0]; | ||
|
|
||
| throw std::runtime_error( | ||
| "Differing CG degrees between input data and model are not supported. File CG degree = " | ||
| + std::to_string(fileCGdegree) + ", model CG degree = " | ||
| + std::to_string(modelCGdegree) + "."); | ||
| } | ||
| // Set the dimensions of CG arrays | ||
| ModelArray::setDimensions(ModelArray::Type::CG, cgDims); | ||
|
|
||
| // Set the data in the kernel arrays. | ||
| // Required data | ||
| for (const auto& fieldName : namedFields) { | ||
|
|
@@ -170,6 +191,15 @@ void BBMDynamics::advectField( | |
| kernel.advectField(timestep, field, lowerLimit, upperLimit); | ||
| } | ||
|
|
||
| ModelState BBMDynamics::getStatePrognostic() const | ||
| { | ||
| return { { | ||
| { uName, kernel.getCGData(uName) }, | ||
| { vName, kernel.getCGData(vName) }, | ||
| { damageName, damage }, | ||
| }, { getConfiguration() } }; | ||
| } | ||
|
|
||
| BBMDynamics::HelpMap& BBMDynamics::getHelpText(HelpMap& map, bool getAll) | ||
| { | ||
| map["BBMDynamics"] = { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -100,22 +100,22 @@ template <int DGadvection> | |
| ModelArray CGDynamicsKernel<DGadvection>::getDG0Data(const std::string& name) const | ||
| { | ||
| if (name == uName) { | ||
| ModelArray data(ModelArray::Type::U); | ||
| ModelArray data(ModelArray::Type::H); | ||
| DGVector<DGadvection> utmp(*smesh); | ||
| Nextsim::Interpolations::CG2DG(*smesh, utmp, u); | ||
| return DGModelArray::dg2ma(utmp, data); | ||
| } else if (name == vName) { | ||
| ModelArray data(ModelArray::Type::V); | ||
| ModelArray data(ModelArray::Type::H); | ||
| DGVector<DGadvection> vtmp(*smesh); | ||
| Nextsim::Interpolations::CG2DG(*smesh, vtmp, v); | ||
| return DGModelArray::dg2ma(vtmp, data); | ||
| } else if (name == uIOStressName) { | ||
| ModelArray data(ModelArray::Type::U); | ||
| ModelArray data(ModelArray::Type::H); | ||
| DGVector<DGadvection> utmp(*smesh); | ||
| Nextsim::Interpolations::CG2DG(*smesh, utmp, uIceOceanStress); | ||
| return DGModelArray::dg2ma(utmp, data); | ||
| } else if (name == vIOStressName) { | ||
| ModelArray data(ModelArray::Type::V); | ||
| ModelArray data(ModelArray::Type::H); | ||
|
Comment on lines
+103
to
+118
Contributor
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. You could now hoist the declaration out of the conditional block to avoid duplication. |
||
| DGVector<DGadvection> vtmp(*smesh); | ||
| Nextsim::Interpolations::CG2DG(*smesh, vtmp, vIceOceanStress); | ||
| return DGModelArray::dg2ma(vtmp, data); | ||
|
|
@@ -124,6 +124,25 @@ ModelArray CGDynamicsKernel<DGadvection>::getDG0Data(const std::string& name) co | |
| } | ||
| } | ||
|
|
||
| template <int DGadvection> | ||
| ModelArray CGDynamicsKernel<DGadvection>::getCGData(const std::string& name) const | ||
| { | ||
| CGField madata(ModelArray::Type::CG); | ||
| madata.resize(); | ||
| if (name == uName) { | ||
| madata = u; | ||
| } else if (name == vName) { | ||
| madata = v; | ||
| } | ||
| return madata; | ||
| } | ||
|
|
||
| template <int DGadvection> | ||
| const ModelArray::MultiDim CGDynamicsKernel<DGadvection>::getCGDimensions() const | ||
| { | ||
| return { CGdegree * smesh->nx + 1, CGdegree * smesh->ny + 1 }; | ||
| } | ||
|
|
||
| template <int DGadvection> void CGDynamicsKernel<DGadvection>::prepareAdvection() | ||
| { | ||
| dgtransport->prepareAdvection(u, v); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
found it 😓
localLengthshould beglobalLength. This part sets the total dimension of the array ready to be written to file. Only the portion of ModelArray will actually be written, but netcdf parallel needs to know the total size so it can write to the correct portion.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.
I tested locally and this fixes the issue with the test
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.
I made this change because a 1 day example run was failing with the following error message. Making the change to
localLengthlet the file writing finish correctly.