| 564 | EasiBoundary::~EasiBoundary() { delete model; } |
| 565 | |
| 566 | void EasiBoundary::query(const real* nodes, real* mapTermsData, real* constantTermsData) const { |
| 567 | if (model == nullptr) { |
| 568 | logError() << "Model for easi-provided boundary is not initialized."; |
| 569 | } |
| 570 | if (tensor::INodal::Shape[1] != 9) { |
| 571 | logError() << "easi-provided boundary data is only supported for elastic material at the " |
| 572 | "moment currently."; |
| 573 | } |
| 574 | assert(mapTermsData != nullptr); |
| 575 | assert(constantTermsData != nullptr); |
| 576 | constexpr auto NumNodes = tensor::INodal::Shape[0]; |
| 577 | auto query = easi::Query{NumNodes, 3}; |
| 578 | size_t offset{0}; |
| 579 | for (unsigned i = 0; i < NumNodes; ++i) { |
| 580 | query.x(i, 0) = nodes[offset++]; |
| 581 | query.x(i, 1) = nodes[offset++]; |
| 582 | query.x(i, 2) = nodes[offset++]; |
| 583 | query.group(i) = 1; |
| 584 | } |
| 585 | const auto& supplied = model->suppliedParameters(); |
| 586 | |
| 587 | // Shear stresses are irrelevant for riemann problem |
| 588 | // Hence they have dummy names and won't be used for this bc. |
| 589 | // We have 9 variables s.t. our tensors have the correct shape. |
| 590 | const auto varNames = |
| 591 | std::array<std::string, 9>{"Tn", "Ts", "Td", "unused1", "unused2", "unused3", "u", "v", "w"}; |
| 592 | |
| 593 | // We read out a affine transformation s.t. val in ghost cell |
| 594 | // is equal to A * val_inside + b |
| 595 | // Note that easi only supports |
| 596 | |
| 597 | // Constant terms stores all terms of the vector b |
| 598 | auto constantTerms = init::easiBoundaryConstant::view::create((constantTermsData)); |
| 599 | |
| 600 | // Map terms stores all terms of the linear map A |
| 601 | auto mapTerms = init::easiBoundaryMap::view::create(mapTermsData); |
| 602 | |
| 603 | easi::ArraysAdapter<real> adapter{}; |
| 604 | |
| 605 | // Constant terms are named const_{varName}, e.g. const_u |
| 606 | offset = 0; |
| 607 | for (const auto& varName : varNames) { |
| 608 | const auto termName = std::string{"const_"} + varName; |
| 609 | if (supplied.count(termName) > 0) { |
| 610 | adapter.addBindingPoint(termName, constantTermsData + offset, constantTerms.shape(0)); |
| 611 | } |
| 612 | ++offset; |
| 613 | } |
| 614 | // Map terms are named map_{varA}_{varB}, e.g. map_u_v |
| 615 | // Mirroring the velocity at the ghost cell would imply the param |
| 616 | // map_u_u: -1 |
| 617 | offset = 0; |
| 618 | for (size_t i = 0; i < varNames.size(); ++i) { |
| 619 | const auto& varName = varNames[i]; |
| 620 | for (size_t j = 0; j < varNames.size(); ++j) { |
| 621 | const auto& otherVarName = varNames[j]; |
| 622 | auto termName = std::string{"map_"}; |
| 623 | termName += varName; |
no test coverage detected