• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

NREL / SolTrace / 18544749821

15 Oct 2025 10:47PM UTC coverage: 89.946% (+45.8%) from 44.166%
18544749821

push

github

web-flow
Restructured backend for SolTrace (#63)

* Initial API for refactored SolTrace

* Updates to various APIs; first pass at element/ray source container implementation

* Use existing matrix-vector code as backend for matrix and vector classes; start implementing APIs

* Created new test on power tower example file with 50000 rays. Changed CMake to use cpp 17.

* Added ground results csv to new folder in google-tests directory

* Removed register prefix from variables in mtrand.h. More errors to come.

* Removed lines in CMakeLists causing linux failure, fixed bug in power tower test

* Created parabola.stinput test and a test using powertower optimization on the powertower sample

* Commented out parabola test for now, added nonexistent branch to CI to see how it runs

* Fixed syntax error

* Changed tests based on PR feedback

* Fixed error in CMakeLists that caused failure on windows

* Removed output messages from st_sim_run_test

* Fixed silly mistake in previous commit

* Added comments and removed unused libraries

* Changed naming conventions of tests

* Added high flux solar furnace test changes, changed parabola test file name

* Fixed typo

* Move refactored data to its own directory; add to refactored classes to build

* Add missed files

* Add unit tests for basic linear algebra and container template

* More tests; Start implementation of composite element

* Add more unit tests on element

* Add missed headers

* Remove target from cmake build command in CI

* Initial virtual element implementation; smoke test for virtual element

* Correct aperture spelling; add tests for virtual elements

* Add some unit tests for simulation data

* Move to static library for simulation data (temporary); update cmake files to get correct mac architecture

* Attempt to fix coverage failure

* Attempt to capture inline functions in code coverage; add a few more explicit tests

* Fix build

* Separate storage of CompositeElement and SingleElement; update te... (continued)

4357 of 4844 new or added lines in 62 files covered. (89.95%)

4357 of 4844 relevant lines covered (89.95%)

8565975.82 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

97.06
/coretrace/simulation_data/container.hpp
1
/**
2
 * @file container.hpp
3
 * @brief Generic container utilities for simulation data
4
 *
5
 * Provides template-based container classes and utilities for
6
 * managing collections of simulation objects. Includes specialized
7
 * containers for elements, apertures, surfaces, and other components
8
 * with shared pointer management.
9
 */
10

11
#ifndef SOLTRACE_ELEMENT_CONTAINER_H
12
#define SOLTRACE_ELEMENT_CONTAINER_H
13

14
#include <cstdint>
15
#include <map>
16
#include <memory>
17

18
namespace SolTrace::Data {
19

20
template <typename K, typename V>
21
class Container
22
{
23
public:
24
    using value_pointer = typename std::shared_ptr<V>;
25
    using iterator = typename std::map<K, value_pointer>::iterator;
26
    using const_iterator = typename std::map<K, value_pointer>::const_iterator;
27

28
    /**
29
     * @brief Create a shared pointer to value type V
30
     * @tparam Args Constructor argument types
31
     * @param args Constructor arguments
32
     * @return Shared pointer to constructed object
33
     */
34
    template<typename... Args>
35
    inline static value_pointer make_pointer(Args&&... args)
36
    {
37
        return std::make_shared<V>(std::forward<Args>(args)...);
38
    }
39

40
    /**
41
     * @brief Create a shared pointer to derived type C
42
     * @tparam C Derived type to construct
43
     * @tparam Args Constructor argument types
44
     * @param args Constructor arguments
45
     * @return Shared pointer to constructed object of type C
46
     */
47
    template<typename C, typename... Args>
48
    inline static std::shared_ptr<C> make_pointer(Args&&... args)
6✔
49
    {
50
        return std::make_shared<C>(std::forward<Args>(args)...);
6✔
51
    }
52

53
    /**
54
     * @brief Constructor with starting ID
55
     * @param start Starting value for ID assignment (default 0)
56
     */
57
    Container(K start=0) : next_id(start) {}
386✔
58

59
    /**
60
     * @brief Destructor - clears all items
61
     */
62
    ~Container() { this->clear(); }
386✔
63

64
    /**
65
     * @brief Add an item to the container
66
     * @param item Shared pointer to item to add
67
     * @return Assigned key/ID for the item (-1 if insertion failed)
68
     */
69
    K add_item(value_pointer item)
17,481✔
70
    {
71
        auto key = this->next_id;
17,481✔
72
        typename std::map<K, value_pointer>::value_type to_insert(key, item);
17,481✔
73
        auto result = this->container.insert(to_insert);
17,481✔
74
        if (result.second == true)
17,481✔
75
        {
76
            ++next_id;
17,481✔
77
        }
78
        else
79
        {
80
            // Insertion failed. The only obvious reason for this is that
81
            // the key is a duplicate. However, given the key is assigned
82
            // by the container itself and is a 64-bit integer, where the
83
            // next id is just incrementing the integer, this should never
84
            // happen. But just in case...
NEW
85
            key = -1;
×
86
        }
87
        return key;
17,481✔
88
    }
17,481✔
89

90
    /**
91
     * @brief Remove an item from the container by key
92
     * @param id Key of item to remove
93
     * @return Number of items removed (0 or 1)
94
     */
95
    auto remove_item(K id)
10✔
96
    {
97
        return this->container.erase(id);
10✔
98
    }
99

100
    /**
101
     * @brief Get an item from the container by key
102
     * @param id Key of item to retrieve
103
     * @return Shared pointer to item, or nullptr if not found
104
     */
105
    value_pointer get_item(K id) const
13,191✔
106
    {
107
        // return this->container[id];
108
        auto item = this->container.find(id);
13,191✔
109
        // value_pointer ptr = (item == this->container.end()
110
        //                          ? std::nullptr_t
111
        //                          : item->second);
112
        // return ptr;
113
        return (item == this->container.end() ? nullptr : item->second);
13,191✔
114
    }
115
    bool replace_item(K id, value_pointer item)
5✔
116
    {
117
        bool retval = false;
5✔
118
        // TODO: What to do here if the item is not in the container?
119
        // For now we fail if the key does not exist as this would otherwise
120
        // be a silent failure. That seems dangerous.
121
        auto pos = this->container.find(id);
5✔
122
        if (pos != this->container.end())
5✔
123
        {
124
            this->container[id] = item;
5✔
125
            retval = true;
5✔
126
        }
127
        return retval;
5✔
128
    }
129

130
    uint_fast64_t get_number_of_items() const
8✔
131
    {
132
        return this->container.size();
8✔
133
    }
134
    // uint64_t get_total_number_of_items() const
135
    // {
136
    //     // TODO: Implement this if needed. For elements, a value can
137
    //     // be a CompositeElement. In this case, it has its own
138
    //     // collection of elements which need to be counted.
139
    //     return 0;
140
    // }
141

142
    void clear()
980✔
143
    {
144
        this->container.clear();
980✔
145
        return;
980✔
146
    }
147

148
    iterator get_iterator() { return container.begin(); }
258✔
149
    const_iterator get_const_iterator() const { return container.cbegin(); }
568✔
150
    bool is_at_end(iterator iter) const { return iter == container.end(); }
2,190✔
151
    bool is_at_end(const_iterator citer) const { return citer == container.cend(); }
18,067✔
152

153
private:
154
    std::map<K, value_pointer> container;
155
    mutable K next_id;
156
};
157

158
} // namespace SolTrace::Data
159

160
#endif
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc