@@ -101,19 +101,19 @@ VarsToReport ReportHandler::get_soma_vars_to_report(const NrnThread& nt,
101101 // only one element for each gid in this case
102102 std::vector<VarWithMapping> to_report;
103103 if (target.find (gid) != target.end ()) {
104- CellMapping* m = mapinfo->get_cell_mapping (gid);
105- if (m == nullptr ) {
104+ const auto & cell_mapping = mapinfo->get_cell_mapping (gid);
105+ if (cell_mapping == nullptr ) {
106106 std::cerr << " [SOMA] Error : Soma mapping information is missing for gid " << gid
107107 << ' \n ' ;
108108 nrn_abort (1 );
109109 }
110110 /* * get section list mapping for soma */
111- SecMapping* s = m ->get_seclist_mapping (" soma" );
111+ const auto & section = cell_mapping ->get_seclist_mapping (" soma" );
112112 /* * 1st key is section-id and 1st value is segment of soma */
113- int section_id = s ->secmap .begin ()->first ;
114- int idx = s ->secmap .begin ()->second .front ();
115- double * variable = report_variable + idx ;
116- to_report.push_back (VarWithMapping (section_id, variable));
113+ int section_id = section ->secmap .begin ()->first ;
114+ int segment_id = section ->secmap .begin ()->second .front ();
115+ double * variable = report_variable + segment_id ;
116+ to_report.emplace_back (VarWithMapping (section_id, variable));
117117 vars_to_report[gid] = to_report;
118118 }
119119 }
@@ -134,7 +134,7 @@ VarsToReport ReportHandler::get_compartment_vars_to_report(const NrnThread& nt,
134134 for (int i = 0 ; i < nt.ncell ; i++) {
135135 int gid = nt.presyns [i].gid_ ;
136136 if (target.find (gid) != target.end ()) {
137- CellMapping* cell_mapping = mapinfo->get_cell_mapping (gid);
137+ const auto & cell_mapping = mapinfo->get_cell_mapping (gid);
138138 if (cell_mapping == nullptr ) {
139139 std::cerr
140140 << " [COMPARTMENTS] Error : Compartment mapping information is missing for gid "
@@ -143,15 +143,16 @@ VarsToReport ReportHandler::get_compartment_vars_to_report(const NrnThread& nt,
143143 }
144144 std::vector<VarWithMapping> to_report;
145145 to_report.reserve (cell_mapping->size ());
146- const auto & secmapvec = cell_mapping->secmapvec ;
147- for (const auto & s : secmapvec) {
148- for (auto & sm : s->secmap ) {
149- int compartment_id = sm.first ;
150- auto & vec = sm.second ;
151- for (const auto & idx : vec) {
146+ const auto & section_mapping = cell_mapping->secmapvec ;
147+ for (const auto & sections : section_mapping) {
148+ for (auto & section : sections->secmap ) {
149+ // compartment_id
150+ int section_id = section.first ;
151+ auto & segment_ids = section.second ;
152+ for (const auto & segment_id : segment_ids) {
152153 /* * corresponding voltage in coreneuron voltage array */
153- double * variable = report_variable + idx ;
154- to_report.push_back (VarWithMapping (compartment_id , variable));
154+ double * variable = report_variable + segment_id ;
155+ to_report.emplace_back (VarWithMapping (section_id , variable));
155156 }
156157 }
157158 }
@@ -192,7 +193,7 @@ VarsToReport ReportHandler::get_section_vars_to_report(const NrnThread& nt,
192193 for (int i = 0 ; i < nt.ncell ; i++) {
193194 int gid = nt.presyns [i].gid_ ;
194195 if (target.find (gid) != target.end ()) {
195- CellMapping* cell_mapping = mapinfo->get_cell_mapping (gid);
196+ const auto & cell_mapping = mapinfo->get_cell_mapping (gid);
196197 if (cell_mapping == nullptr ) {
197198 std::cerr
198199 << " [COMPARTMENTS] Error : Compartment mapping information is missing for gid "
@@ -204,24 +205,25 @@ VarsToReport ReportHandler::get_section_vars_to_report(const NrnThread& nt,
204205
205206 /* * get section list mapping for the type, if available */
206207 if (cell_mapping->get_seclist_section_count (section_type_str) > 0 ) {
207- SecMapping* s = cell_mapping->get_seclist_mapping (section_type_str);
208- for (const auto & sm : s->secmap ) {
209- int compartment_id = sm.first ;
210- const auto & vec = sm.second ;
208+ const auto & sections = cell_mapping->get_seclist_mapping (section_type_str);
209+ for (const auto & section : sections->secmap ) {
210+ // compartment_id
211+ int section_id = section.first ;
212+ const auto & segment_ids = section.second ;
211213
212214 /* * get all compartment values (otherwise, just middle point) */
213215 if (all_compartments) {
214- for (const auto & idx : vec ) {
216+ for (const auto & segment_id : segment_ids ) {
215217 /* * corresponding voltage in coreneuron voltage array */
216- double * variable = report_variable + idx ;
217- to_report.push_back (VarWithMapping (compartment_id , variable));
218+ double * variable = report_variable + segment_id ;
219+ to_report.emplace_back (VarWithMapping (section_id , variable));
218220 }
219221 } else {
220- nrn_assert (vec .size () % 2 );
222+ nrn_assert (segment_ids .size () % 2 );
221223 /* * corresponding voltage in coreneuron voltage array */
222- const auto idx = vec[vec .size () / 2 ];
223- double * variable = report_variable + idx ;
224- to_report.push_back (VarWithMapping (compartment_id , variable));
224+ const auto segment_id = segment_ids[segment_ids .size () / 2 ];
225+ double * variable = report_variable + segment_id ;
226+ to_report.emplace_back (VarWithMapping (section_id , variable));
225227 }
226228 }
227229 vars_to_report[gid] = to_report;
0 commit comments