| 53 | } |
| 54 | |
| 55 | void initializeCellMaterial(seissol::SeisSol& seissolInstance) { |
| 56 | const auto& seissolParams = seissolInstance.getSeisSolParameters(); |
| 57 | const auto& meshReader = seissolInstance.meshReader(); |
| 58 | initializer::MemoryManager& memoryManager = seissolInstance.getMemoryManager(); |
| 59 | |
| 60 | // unpack ghost layer (merely a re-ordering operation, since the CellToVertexArray right now |
| 61 | // requires an vector there) |
| 62 | std::vector<std::array<std::array<double, 3>, 4>> ghostVertices; |
| 63 | std::vector<int> ghostGroups; |
| 64 | std::unordered_map<int, std::vector<unsigned>> ghostIdxMap; |
| 65 | for (const auto& neighbor : meshReader.getGhostlayerMetadata()) { |
| 66 | ghostIdxMap[neighbor.first].reserve(neighbor.second.size()); |
| 67 | for (const auto& metadata : neighbor.second) { |
| 68 | ghostIdxMap[neighbor.first].push_back(ghostVertices.size()); |
| 69 | std::array<std::array<double, 3>, 4> vertices{}; |
| 70 | for (size_t i = 0; i < 4; ++i) { |
| 71 | for (size_t j = 0; j < 3; ++j) { |
| 72 | vertices[i][j] = metadata.vertices[i][j]; |
| 73 | } |
| 74 | } |
| 75 | ghostVertices.emplace_back(vertices); |
| 76 | ghostGroups.push_back(metadata.group); |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | // just a helper function for better readability |
| 81 | auto getBestQueryGenerator = [&](const seissol::initializer::CellToVertexArray& ctvArray) { |
| 82 | return seissol::initializer::getBestQueryGenerator( |
| 83 | seissol::initializer::parameters::isModelAnelastic(), |
| 84 | seissolParams.model.plasticity, |
| 85 | seissol::initializer::parameters::isModelAnisotropic(), |
| 86 | seissol::initializer::parameters::isModelPoroelastic(), |
| 87 | seissolParams.model.useCellHomogenizedMaterial, |
| 88 | ctvArray); |
| 89 | }; |
| 90 | |
| 91 | // material retrieval for copy+interior layers |
| 92 | seissol::initializer::QueryGenerator* queryGen = |
| 93 | getBestQueryGenerator(seissol::initializer::CellToVertexArray::fromMeshReader(meshReader)); |
| 94 | auto materialsDB = queryDB<MaterialT>( |
| 95 | queryGen, seissolParams.model.materialFileName, meshReader.getElements().size()); |
| 96 | |
| 97 | // plasticity (if needed) |
| 98 | std::vector<Plasticity> plasticityDB; |
| 99 | if (seissolParams.model.plasticity) { |
| 100 | // plasticity information is only needed on all interior+copy cells. |
| 101 | plasticityDB = queryDB<Plasticity>( |
| 102 | queryGen, seissolParams.model.materialFileName, meshReader.getElements().size()); |
| 103 | } |
| 104 | |
| 105 | // material retrieval for ghost layers |
| 106 | seissol::initializer::QueryGenerator* queryGenGhost = getBestQueryGenerator( |
| 107 | seissol::initializer::CellToVertexArray::fromVectors(ghostVertices, ghostGroups)); |
| 108 | auto materialsDBGhost = |
| 109 | queryDB<MaterialT>(queryGenGhost, seissolParams.model.materialFileName, ghostVertices.size()); |
| 110 | |
| 111 | #if defined(USE_VISCOELASTIC) || defined(USE_VISCOELASTIC2) |
| 112 | // we need to compute all model parameters before we can use them... |
no test coverage detected