-
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
Small: Fix bug in sparse packs that include fluxes #1088
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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 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 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 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 |
---|---|---|
|
@@ -110,6 +110,7 @@ SparsePackBase SparsePackBase::Build(T *pmd, const PackDescriptor &desc, | |
int max_size = 0; | ||
int nblocks = 0; | ||
bool contains_face_or_edge = false; | ||
bool contains_face_with_fluxes = false; | ||
int size = 0; // local var used to compute size/block | ||
ForEachBlock(pmd, include_block, [&](int b, mbd_t *pmbd) { | ||
if (!desc.flat) { | ||
|
@@ -122,8 +123,13 @@ SparsePackBase SparsePackBase::Build(T *pmd, const PackDescriptor &desc, | |
if (uid_map.count(uid) > 0) { | ||
const auto pv = uid_map.at(uid); | ||
if (pv->IsAllocated()) { | ||
if (pv->IsSet(Metadata::Face) || pv->IsSet(Metadata::Edge)) | ||
if (pv->IsSet(Metadata::Edge)) contains_face_or_edge = true; | ||
if (pv->IsSet(Metadata::Face)) { | ||
if (pv->IsSet(Metadata::WithFluxes) && desc.with_fluxes) { | ||
contains_face_with_fluxes = true; | ||
} | ||
contains_face_or_edge = true; | ||
} | ||
int prod = pv->GetDim(6) * pv->GetDim(5) * pv->GetDim(4); | ||
size += prod; // max size/block (or total size for flat) | ||
pack.size_ += prod; // total ragged size | ||
|
@@ -138,7 +144,11 @@ SparsePackBase SparsePackBase::Build(T *pmd, const PackDescriptor &desc, | |
|
||
// Allocate the views | ||
int leading_dim = 1; | ||
if (desc.with_fluxes) { | ||
pack.flx_idx_ = 1; | ||
if (contains_face_with_fluxes) { | ||
leading_dim += 5; | ||
pack.flx_idx_ = 3; | ||
} else if (desc.with_fluxes) { | ||
leading_dim += 3; | ||
} else if (contains_face_or_edge) { | ||
leading_dim += 2; | ||
|
@@ -205,11 +215,11 @@ SparsePackBase SparsePackBase::Build(T *pmd, const PackDescriptor &desc, | |
|
||
if (pv->IsSet(Metadata::Face)) { | ||
pack.pack_h_(0, b, idx).topological_element = | ||
TopologicalElement::E1; | ||
TopologicalElement::F1; | ||
pack.pack_h_(1, b, idx).topological_element = | ||
TopologicalElement::E2; | ||
TopologicalElement::F2; | ||
pack.pack_h_(2, b, idx).topological_element = | ||
TopologicalElement::E3; | ||
TopologicalElement::F3; | ||
Comment on lines
216
to
+222
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. Was this a true bug? 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. It was, but I don't think anyone code has actually used this information. |
||
} | ||
|
||
} else { // This is a cell, node, or a variable that doesn't have | ||
|
@@ -221,13 +231,16 @@ SparsePackBase SparsePackBase::Build(T *pmd, const PackDescriptor &desc, | |
} | ||
if (pv->IsSet(Metadata::Vector)) | ||
pack.pack_h_(0, b, idx).vector_component = v + 1; | ||
} | ||
|
||
if (desc.with_fluxes && pv->IsSet(Metadata::WithFluxes)) { | ||
pack.pack_h_(1, b, idx) = pvf->data.Get(0, t, u, v); | ||
pack.pack_h_(2, b, idx) = pvf->data.Get(1, t, u, v); | ||
pack.pack_h_(3, b, idx) = pvf->data.Get(2, t, u, v); | ||
if (desc.with_fluxes && pv->IsSet(Metadata::WithFluxes)) { | ||
pack.pack_h_(0 + pack.flx_idx_, b, idx) = pvf->data.Get(0, t, u, v); | ||
if (!pv->IsSet(Metadata::Edge)) { | ||
pack.pack_h_(1 + pack.flx_idx_, b, idx) = pvf->data.Get(1, t, u, v); | ||
pack.pack_h_(2 + pack.flx_idx_, b, idx) = pvf->data.Get(2, t, u, v); | ||
} | ||
} | ||
|
||
for (auto el : | ||
GetTopologicalElements(pack.pack_h_(0, b, idx).topological_type)) { | ||
pack.pack_h_(static_cast<int>(el) % 3, b, idx).topological_element = | ||
|
This file contains 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 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 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.
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.
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.
5 because of the face itself and 4 edges/fluxes?
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.
leading_dim
starts at 1, so this makes it 6. When a face has fluxes, the face itself has 3 components and the edge flux has 3 components.