| Base 7edd10 | Head #31782 615931 | ||||
|---|---|---|---|---|---|
| Total | Total | +/- | New | ||
| Rate | 85.97% | 85.97% | -0.00% | 100.00% | |
| Hits | 124954 | 125086 | +132 | 162 | |
| Misses | 20387 | 20411 | +24 | 0 | |
| Filename | Stmts | Miss | Cover |
|---|---|---|---|
| framework/include/csg/CSGBase.h | +4 | 0 | +100.00% |
| framework/include/csg/CSGCellList.h | +3 | 0 | +100.00% |
| framework/include/csg/CSGPlane.h | +2 | +2 | -66.67% |
| framework/include/csg/CSGSphere.h | +2 | 0 | +100.00% |
| framework/include/csg/CSGSurfaceList.h | +4 | 0 | +100.00% |
| framework/include/csg/CSGUniverseList.h | +4 | 0 | +100.00% |
| framework/include/csg/CSGXCylinder.h | +2 | +2 | -66.67% |
| framework/include/csg/CSGYCylinder.h | +2 | +2 | -66.67% |
| framework/include/csg/CSGZCylinder.h | +2 | +2 | -66.67% |
| framework/src/base/MeshGeneratorSystem.C | +10 | 0 | +0.26% |
| framework/src/csg/CSGBase.C | +48 | 0 | +100.00% |
| framework/src/csg/CSGCellList.C | +16 | +5 | -9.06% |
| framework/src/csg/CSGPlane.C | +9 | 0 | +100.00% |
| framework/src/csg/CSGRegion.C | +2 | +1 | -0.93% |
| framework/src/csg/CSGSurfaceList.C | +20 | +4 | -6.76% |
| framework/src/csg/CSGUniverse.C | 0 | -3 | +6.25% |
| framework/src/csg/CSGUniverseList.C | +16 | +5 | -8.76% |
| framework/src/meshgenerators/MeshGenerator.C | -2 | -8 | +3.35% |
| framework/src/utils/CSGUtils.C | +12 | +12 | +100.00% |
| TOTAL | +156 | +24 | -0.00% |
codecodecode+
45 46 47 48 + 49 50 51 |
~CSGBase(); /// Create a deep copy of this CSGBase instance std::unique_ptr<CSGBase> clone() const { return std::make_unique<CSGBase>(*this); } /** * @brief add a unique surface pointer to this base instance |
353 354 355 356 + 357 358 359 |
* * @return CSGSurfaceList */ const CSGSurfaceList & getSurfaceList() const { return _surface_list; } /** * @brief Get a non-const reference to the CSGSurfaceList object |
367 368 369 370 + 371 372 373 |
* * @return CSGCellList */ const CSGCellList & getCellList() const { return _cell_list; } /** * @brief Get a non-const reference to the CSGCellList object |
381 382 383 384 + 385 386 387 |
* * @return CSGUniverseList */ const CSGUniverseList & getUniverseList() const { return _universe_list; } /** * @brief Get a non-const reference to the CSGUniverseList object |
70 71 72 73 + 74 75 76 |
* @param name name of cell * @return true if cell name exists, false otherwise */ bool hasCell(const std::string & name) const { return _cells.find(name) != _cells.end(); } /** * @brief Get non-const map of all names to cells in cell list |
84 85 86 87 + 88 89 + 90 91 92 |
* * @return map of all names to CSGCell pointers */ const std::unordered_map<std::string, std::unique_ptr<CSGCell>> & getCellListMap() const { return _cells; } /** |
72 73 74 75 + 76 77 + 78 79 80 |
* * @return std::unordered_map<CSGSurface> unique_ptr to cloned plane */ virtual std::unique_ptr<CSGSurface> clone() const override { return std::make_unique<CSGPlane>(_name, _a, _b, _c, _d); } // calculate the equivalent coeffients (aX + bY + cZ = d) from 3 points on a plane |
67 68 69 70 + 71 72 + 73 74 75 |
* * @return std::unordered_map<CSGSurface> unique_ptr to cloned sphere */ virtual std::unique_ptr<CSGSurface> clone() const override { return std::make_unique<CSGSphere>(_name, Point(_x0, _y0, _z0), _r); } // check that radius is positive |
42 43 44 45 + 46 47 48 |
*/ std::unordered_map<std::string, std::unique_ptr<CSGSurface>> & getSurfaceListMap() { return _surfaces; } /** |
50 51 52 53 + 54 55 56 |
* * @return map of all names to CSGSurface pointers */ const std::unordered_map<std::string, std::unique_ptr<CSGSurface>> & getSurfaceListMap() const { return _surfaces; } |
68 69 70 71 + 72 73 + 74 75 76 |
* @param name name of surface * @return true if surface name exists, false otherwise */ bool hasSurface(const std::string & name) const { return _surfaces.find(name) != _surfaces.end(); } /** |
44 45 46 47 + 48 49 + 50 51 52 |
* @param name name of universe * @return true if universe name exists, false otherwise */ bool hasUniverse(const std::string & name) const { return _universes.find(name) != _universes.end(); } /** |
56 57 58 59 + 60 61 62 |
*/ std::unordered_map<std::string, std::unique_ptr<CSGUniverse>> & getUniverseListMap() { return _universes; } /** |
64 65 66 67 + 68 69 70 |
* * @return map of all names to CSGUniverse pointers */ const std::unordered_map<std::string, std::unique_ptr<CSGUniverse>> & getUniverseListMap() const { return _universes; } |
60 61 62 63 + 64 65 + 66 67 68 |
* * @return std::unordered_map<CSGSurface> unique_ptr to cloned x-cylinder */ virtual std::unique_ptr<CSGSurface> clone() const override { return std::make_unique<CSGXCylinder>(_name, _y0, _z0, _r); } // check that radius is positive |
60 61 62 63 + 64 65 + 66 67 68 |
* * @return std::unordered_map<CSGSurface> unique_ptr to cloned y-cylinder */ virtual std::unique_ptr<CSGSurface> clone() const override { return std::make_unique<CSGYCylinder>(_name, _x0, _z0, _r); } // check that radius is positive |
60 61 62 63 + 64 65 + 66 67 68 |
* * @return std::unordered_map<CSGSurface> unique_ptr to cloned z-cylinder */ virtual std::unique_ptr<CSGSurface> clone() const override { return std::make_unique<CSGZCylinder>(_name, _x0, _y0, _r); } // check that radius is positive |
581 582 583 584 + 585 586 587 + 588 589 590 |
_mesh_generators.emplace(generator_name, mg); mooseAssert(!_mesh_generator_outputs.count(generator_name), "Already exists"); _mesh_generator_outputs[generator_name]; if (getCSGOnly()) { mooseAssert(!_csg_base_outputs.count(generator_name), "CSG already exists"); _csg_base_outputs[generator_name]; } _mesh_generator_params.erase(find_params); |
703 704 705 706 + 707 708 709 710 + 711 712 713 + 714 + 715 + 716 + 717 718 + 719 + 720 721 722 |
MeshGeneratorSystem::saveOutputCSGBase(const MeshGeneratorName generator_name, std::unique_ptr<CSG::CSGBase> & csg_base) { auto & outputs = _csg_base_outputs[generator_name]; // Store CSGBase instance for any downstream MG's that request it, creating copies // as needed if (outputs.size()) { // Set first output to csg_base auto & first_output = *outputs.begin(); first_output = std::move(csg_base); const auto & copy_from = *first_output; auto output_it = ++outputs.begin(); // For all of the rest we create a clone of csg_base for (; output_it != outputs.end(); ++output_it) (*output_it) = copy_from.clone(); } } |
727 728 729 730 + 731 732 + 733 + 734 735 |
_app.actionWarehouse().getCurrentTaskName() == "execute_mesh_generators", "Incorrect call time"); auto it = _csg_base_outputs.find(name); mooseAssert(it != _csg_base_outputs.end(), "CSG mesh not initialized"); it->second.push_back(nullptr); return it->second.back(); } |
17 18 19 20 + 21 + 22 + 23 + 24 25 26 27 28 + 29 + 30 31 32 + 33 34 + 35 + 36 37 38 39 40 41 + 42 + 43 + 44 45 46 47 48 + 49 50 51 + 52 + 53 + 54 55 56 + 57 + 58 + 59 + 60 + 61 62 + 63 + 64 + 65 66 67 68 69 + 70 + 71 72 + 73 74 75 + 76 77 78 + 79 + 80 + 81 82 83 84 85 + 86 + 87 + 88 + 89 + 90 + 91 92 93 |
{ } CSGBase::CSGBase(const CSGBase & other_base) : _surface_list(other_base.getSurfaceList()), _cell_list(CSGCellList()), _universe_list(CSGUniverseList()) { // Iterate through all cell references from the other CSGBase instance and // create new CSGCell pointers based on these references. This is done // recursively to properly handle cells with universe fills for (const auto & [name, cell] : other_base.getCellList().getCellListMap()) addCellToList(*cell); // Link all cells in other_base root universe to current root universe for (auto & root_cell : other_base.getRootUniverse().getAllCells()) { const auto & list_cell = _cell_list.getCell(root_cell.get().getName()); addCellToUniverse(getRootUniverse(), list_cell); } // Iterate through all universe references from the other CSGBase instance and // create new CSGUniverse pointers based on these references. This is done in case // any universe exist in the universe list that are not connected to the cell list. for (const auto & [name, univ] : other_base.getUniverseList().getUniverseListMap()) addUniverseToList(*univ); } CSGBase::~CSGBase() {} const CSGCell & CSGBase::addCellToList(const CSGCell & cell) { // If cell has already been created, we just return a reference to it const auto name = cell.getName(); if (_cell_list.hasCell(name)) return _cell_list.getCell(name); // Otherwise if the cell has material or void cell, we can create it directly const auto fill_type = cell.getFillType(); const auto region = cell.getRegion(); if (fill_type == "VOID") return _cell_list.addVoidCell(name, region); else if (fill_type == "CSG_MATERIAL") { const auto mat_name = cell.getFillMaterial(); return _cell_list.addMaterialCell(name, mat_name, region); } // Otherwise if the cell has a universe fill, we need to recursively define // all linked universes and cells first before defining this cell else { const auto & univ = addUniverseToList(cell.getFillUniverse()); return _cell_list.addUniverseCell(name, univ, region); } } const CSGUniverse & CSGBase::addUniverseToList(const CSGUniverse & univ) { // If universe has already been created, we just return a reference to it const auto name = univ.getName(); if (_universe_list.hasUniverse(name)) return _universe_list.getUniverse(name); // Otherwise we create a new universe based on its associated cells. // addCellToList is called recursively in case associated cells have not // been added to the cell list yet. const auto univ_cells = univ.getAllCells(); std::vector<std::reference_wrapper<const CSGCell>> current_univ_cells; for (const auto & univ_cell : univ_cells) current_univ_cells.push_back(addCellToList(univ_cell)); return createUniverse(name, current_univ_cells); } const CSGCell & CSGBase::createCell(const std::string & name, |
438 439 440 441 + 442 443 + 444 + 445 + 446 + 447 + 448 + 449 + 450 + 451 452 453 454 + 455 456 + 457 458 459 |
} bool CSGBase::operator==(const CSGBase & other) const { const auto & surf_list = this->getSurfaceList(); const auto & other_surf_list = other.getSurfaceList(); const auto & cell_list = this->getCellList(); const auto & other_cell_list = other.getCellList(); const auto & univ_list = this->getUniverseList(); const auto & other_univ_list = other.getUniverseList(); return (surf_list == other_surf_list) && (cell_list == other_cell_list) && (univ_list == other_univ_list); } bool CSGBase::operator!=(const CSGBase & other) const { return !(*this == other); } } // namespace CSG |
81 82 83 84 + 85 86 + 87 + 88 89 90 + 91 + 92 93 94 95 + 96 97 + 98 + 99 + 100 + 101 + 102 + 103 104 + 105 + 106 107 108 + 109 110 + 111 112 113 |
} bool CSGCellList::operator==(const CSGCellList & other) const { const auto all_cells = this->getAllCells(); const auto other_cells = other.getAllCells(); // Check that same number of cells are defined in both lists if (all_cells.size() != other_cells.size()) return false; // Iterate through each CSGCell in list and check equality of each cell // with other list for (const auto & cell : all_cells) { const auto & cell_name = cell.get().getName(); if (!other.hasCell(cell_name)) return false; const auto & other_cell = other.getCell(cell_name); if (cell.get() != other_cell) return false; } return true; } bool CSGCellList::operator!=(const CSGCellList & other) const { return !(*this == other); } } // namespace CSG |
16 17 18 19 + 20 21 22 23 24 25 + 26 27 28 |
: CSGSurface(name, MooseUtils::prettyCppType<CSGPlane>()) { coeffsFromPoints(p1, p2, p3); normalizePlaneCoefficients(); } CSGPlane::CSGPlane(const std::string & name, const Real a, const Real b, const Real c, const Real d) : CSGSurface(name, MooseUtils::prettyCppType<CSGPlane>()), _a(a), _b(b), _c(c), _d(d) { normalizePlaneCoefficients(); } std::unordered_map<std::string, Real> |
52 53 54 55 + 56 57 + 58 + 59 + 60 + 61 + 62 + 63 64 65 |
} void CSGPlane::normalizePlaneCoefficients() { const auto k = 1. / std::sqrt(_a * _a + _b * _b + _c * _c); _a *= k; _b *= k; _c *= k; _d *= k; } Real CSGPlane::evaluateSurfaceEquationAtPoint(const Point & p) const |
60 61 62 63 + 64 + 65 66 + 67 68 69 |
if (getRegionType() == RegionType::COMPLEMENT) { // no change to surfaces, but update string if (region.toString()[0] == '(') _region_str = "~" + region.toString(); else _region_str = "~(" + region.toString() + ")"; _surfaces = region.getSurfaces(); } else if (getRegionType() == RegionType::EMPTY) |
19 20 21 22 + 23 24 + 25 + 26 + 27 28 29 |
CSGSurfaceList::CSGSurfaceList() {} CSGSurfaceList::CSGSurfaceList(const CSGSurfaceList & other_surface_list) { for (const auto & [name, surf] : other_surface_list.getSurfaceListMap()) _surfaces.emplace(name, surf->clone()); } CSGSurface & CSGSurfaceList::getSurface(const std::string & name) const |
71 72 73 74 + 75 76 + 77 + 78 79 80 + 81 + 82 83 84 85 + 86 87 + 88 + 89 + 90 + 91 + 92 + 93 94 + 95 + 96 97 98 + 99 100 + 101 102 103 |
} bool CSGSurfaceList::operator==(const CSGSurfaceList & other) const { const auto all_surfs = this->getAllSurfaces(); const auto other_surfs = other.getAllSurfaces(); // Check that same number of surfaces are defined in both lists if (all_surfs.size() != other_surfs.size()) return false; // Iterate through each CSGSurface in list and check equality of surface // with other list for (const auto & surf : all_surfs) { const auto & surf_name = surf.get().getName(); if (!other.hasSurface(surf_name)) return false; const auto & other_surf = other.getSurface(surf_name); if (surf.get() != other_surf) return false; } return true; } bool CSGSurfaceList::operator!=(const CSGSurfaceList & other) const { return !(*this == other); } } // namespace CSG |
78 79 80 81 82 83 84 |
if (num_cells_eq) { for (unsigned int i = 0; i < all_cells.size(); ++i) if (all_cells[i].get() != other_cells[i].get()) return false; return true; } |
90 91 92 93 94 95 96 97 98 |
} bool CSGUniverse::operator!=(const CSGUniverse & other) const { return !(*this == other); } } // namespace CSG |
74 75 76 77 + 78 79 + 80 + 81 82 83 + 84 + 85 86 87 88 + 89 90 + 91 + 92 + 93 + 94 + 95 + 96 97 + 98 + 99 100 101 + 102 103 + 104 105 106 |
} bool CSGUniverseList::operator==(const CSGUniverseList & other) const { const auto all_univs = this->getAllUniverses(); const auto other_univs = other.getAllUniverses(); // Check that same number of universes are defined in both lists if (all_univs.size() != other_univs.size()) return false; // Iterate through each CSGUniverse in list and check equality of universe // with other list for (const auto & univ : all_univs) { const auto & univ_name = univ.get().getName(); if (!other.hasUniverse(univ_name)) return false; const auto & other_univ = other.getUniverse(univ_name); if (univ.get() != other_univ) return false; } return true; } bool CSGUniverseList::operator!=(const CSGUniverseList & other) const { return !(*this == other); } } // namespace CSG |
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 |
} std::vector<std::unique_ptr<CSG::CSGBase> *> MeshGenerator::getCSGBases(const std::string & param_name) { return getCSGBasesByName(getMeshGeneratorNamesFromParam(param_name)); } std::vector<std::unique_ptr<CSG::CSGBase> *> MeshGenerator::getCSGBasesByName(const std::vector<MeshGeneratorName> & mesh_generator_names) { std::vector<std::unique_ptr<CSG::CSGBase> *> csg_bases; for (const auto & name : mesh_generator_names) csg_bases.push_back(&getCSGBaseByName(name)); return csg_bases; } void |
16 17 18 19 + 20 21 22 + 23 + 24 25 + 26 + 27 + 28 + 29 + 30 + 31 + 32 + 33 + 34 35 |
{ CSGRegion getInnerRegion(const std::vector<std::reference_wrapper<const CSGSurface>> & surfaces, const libMesh::Point & origin) { CSGRegion inner_region; for (const auto & surf_ref : surfaces) { const auto & surf = surf_ref.get(); const auto direction = surf.getHalfspaceFromPoint(origin); auto halfspace = (direction == CSGSurface::Halfspace::POSITIVE) ? +surf : -surf; inner_region = (inner_region.getRegionType() == CSGRegion::RegionType::EMPTY) ? halfspace : inner_region & halfspace; } return inner_region; } } |