Closed tjfulle closed 7 years ago
If you are using STK discretization, then you could (with a little bit of effort) get it by getting the discretization out of the workset, casting it down to STKDiscretization, get the current bucket of cells from the stk mesh struct and check their identifier with the identifier method of the stk mesh struct's bulkData.
A bit contorted, and only working with STK discretizations, but should do the job. Also, you need ALBANY_EPETRA to be defined, otherwise the workset does not store a pointer to the discretization.
Otherwise I don't think the abstract discretization has a method for you. It does store the opposite of what you need (given elem GID, get its wsId and LID), so you could probably easily implement an inverse map of that... But you would always need ALBANY_EPETRA to be defined.
Note: you could think of making it so that the workset always stores the pointer to the discretization, not just when ALBANY_EPETRA is defined. After all, it's just a pointer.
Thanks @bartgol! That does seem a bit convoluted, but I can give it a try. In another part of the code I already build maps to map global element IDs from the STK discretization to the discretization of the external code (for the solution transfer), so it may not be a stretch to, at the same time, generate a map from wsID and LID to GID.
Thanks for the help @bartgol. I resolved the problem by inverting the map stkDisc.getElemGIDws
(as you suggested) which gives the workset ID and element LID as a function of GID.
For posterity sake, I implemented the inversion as:
// Create data structure for obtaining the global element id given the workset
// index and workset local element id.
Albany::WsLIDList ws_LID_list = stk_disc->getElemGIDws();
for(auto const & it : ws_LID_list) {
int el_gid = it.first;
int ws_idx = it.second.ws;
int ws_lid = it.second.LID;
std::vector<global_ordinal_type>& ws_gids = WS_lid_to_gid[ws_idx];
TEUCHOS_TEST_FOR_EXCEPT_MSG(ws_lid != ws_gids.size(),
"\n\n**** Error in PFLOTRAN_Manager::initialize(), "
"unexpected workset local id.\n\n");
ws_gids.push_back(el_gid);
}
I have written an evaluator that during
evaluateFields
, rather than compute the updated field values, it retrieves them from another code (this is a multiphysics problem with the other code supplying data). To retrieve the proper values I need the global element ID associated with the cell. Is there a mapping from local cell IDs to global element IDs that I can use for this?