@@ -179,6 +179,7 @@ COutput::COutput(const CConfig *config, unsigned short ndim, bool fem_output):
179179 curTimeIter = 0 ;
180180
181181 volumeDataSorter = nullptr ;
182+ volumeDataSorterCompact = nullptr ;
182183 surfaceDataSorter = nullptr ;
183184
184185 headerNeeded = false ;
@@ -195,6 +196,7 @@ COutput::~COutput() {
195196 delete fileWritingTable;
196197 delete historyFileTable;
197198 delete volumeDataSorter;
199+ delete volumeDataSorterCompact;
198200 delete surfaceDataSorter;
199201
200202}
@@ -343,6 +345,9 @@ void COutput::AllocateDataSorters(CConfig *config, CGeometry *geometry){
343345 if (volumeDataSorter == nullptr )
344346 volumeDataSorter = new CFEMDataSorter (config, geometry, volumeFieldNames);
345347
348+ if (volumeDataSorterCompact == nullptr )
349+ volumeDataSorterCompact = new CFEMDataSorter (config, geometry, requiredVolumeFieldNames);
350+
346351 if (surfaceDataSorter == nullptr )
347352 surfaceDataSorter = new CSurfaceFEMDataSorter (config, geometry,
348353 dynamic_cast <CFEMDataSorter*>(volumeDataSorter));
@@ -352,6 +357,9 @@ void COutput::AllocateDataSorters(CConfig *config, CGeometry *geometry){
352357 if (volumeDataSorter == nullptr )
353358 volumeDataSorter = new CFVMDataSorter (config, geometry, volumeFieldNames);
354359
360+ if (volumeDataSorterCompact == nullptr )
361+ volumeDataSorterCompact = new CFVMDataSorter (config, geometry, requiredVolumeFieldNames);
362+
355363 if (surfaceDataSorter == nullptr )
356364 surfaceDataSorter = new CSurfaceFVMDataSorter (config, geometry,
357365 dynamic_cast <CFVMDataSorter*>(volumeDataSorter));
@@ -461,12 +469,15 @@ void COutput::WriteToFile(CConfig *config, CGeometry *geometry, OUTPUT_TYPE form
461469
462470 /* --- If we have compact restarts, we use only the required fields. ---*/
463471 if (config->GetWrt_Restart_Compact ())
464- volumeDataSorter ->SetRequiredFieldNames (requiredVolumeFieldNames);
472+ volumeDataSorterCompact ->SetRequiredFieldNames (requiredVolumeFieldNames);
465473 else
466474 volumeDataSorter->SetRequiredFieldNames (volumeDataSorter->GetFieldNames ());
467475
468476 LogOutputFiles (" SU2 binary restart" );
469- fileWriter = new CSU2BinaryFileWriter (volumeDataSorter);
477+ if (config->GetWrt_Restart_Compact ())
478+ fileWriter = new CSU2BinaryFileWriter (volumeDataSorterCompact);
479+ else
480+ fileWriter = new CSU2BinaryFileWriter (volumeDataSorter);
470481
471482 break ;
472483
@@ -846,6 +857,7 @@ bool COutput::SetResultFiles(CGeometry *geometry, CConfig *config, CSolver** sol
846857 /* --- Partition and sort the data --- */
847858
848859 volumeDataSorter->SortOutputData ();
860+ volumeDataSorterCompact->SortOutputData ();
849861
850862 if (rank == MASTER_NODE && !isFileWrite) {
851863 fileWritingTable->SetAlign (PrintingToolbox::CTablePrinter::CENTER);
@@ -1554,24 +1566,32 @@ void COutput::PreprocessVolumeOutput(CConfig *config){
15541566 * object gets an offset so that we know where to find the data in the Local_Data() array.
15551567 * Note that the default offset is -1. An index !=-1 defines this field as part of the output. ---*/
15561568
1569+ unsigned short nVolumeFieldsCompact = 0 ;
1570+
15571571 for (size_t iField_Output = 0 ; iField_Output < volumeOutput_List.size (); iField_Output++) {
15581572
15591573 const string &fieldReference = volumeOutput_List[iField_Output];
1560-
15611574 if (volumeOutput_Map.count (fieldReference) > 0 ) {
1562-
15631575 VolumeOutputField &Field = volumeOutput_Map.at (fieldReference);
1576+
15641577 /* --- Loop through all fields specified in the config ---*/
1578+
15651579 for (size_t iReqField = 0 ; iReqField < restartVolumeFields.size (); iReqField++) {
15661580
1581+ // minimum required fields for restarts
15671582 RequiredField = restartVolumeFields[iReqField];
1583+
15681584 if (((RequiredField == Field.outputGroup ) || (RequiredField == fieldReference)) && (Field.offset == -1 )) {
1585+ Field.offsetCompact = nVolumeFieldsCompact;
15691586 requiredVolumeFieldNames.push_back (Field.fieldName );
1587+ nVolumeFieldsCompact++;
15701588 }
15711589 }
15721590 }
15731591 }
15741592
1593+ // volumeDataSorter->SetRequiredFieldNames(requiredVolumeFieldNames);
1594+
15751595 unsigned short nVolumeFields = 0 ;
15761596
15771597 for (size_t iField_Output = 0 ; iField_Output < volumeOutput_List.size (); iField_Output++) {
@@ -1716,16 +1736,25 @@ void COutput::LoadDataIntoSorter(CConfig* config, CGeometry* geometry, CSolver**
17161736
17171737void COutput::SetVolumeOutputValue (const string& name, unsigned long iPoint, su2double value){
17181738
1719- if (buildFieldIndexCache){
1739+ const vector<string> reqFieldNames = requiredVolumeFieldNames;
1740+ string fieldname = volumeOutput_Map.at (name).fieldName ;
1741+ bool contains = std::any_of (requiredVolumeFieldNames.begin (), requiredVolumeFieldNames.end (),
1742+ [fieldname](string n) { return n == fieldname; });
1743+ if (buildFieldIndexCache) {
17201744
17211745 /* --- Build up the offset cache to speed up subsequent
17221746 * calls of this routine since the order of calls is
17231747 * the same for every value of iPoint --- */
17241748
1725- if (volumeOutput_Map.count (name) > 0 ){
1749+ if (volumeOutput_Map.count (name) > 0 ) {
17261750 const short Offset = volumeOutput_Map.at (name).offset ;
17271751 fieldIndexCache.push_back (Offset);
17281752 if (Offset != -1 ){
1753+ // note that the compact fields are a subset of the full fields
1754+ if (contains == true ) {
1755+ const short OffsetCompact = volumeOutput_Map.at (name).offsetCompact ;
1756+ volumeDataSorterCompact->SetUnsortedData (iPoint, OffsetCompact, value);
1757+ }
17291758 volumeDataSorter->SetUnsortedData (iPoint, Offset, value);
17301759 }
17311760 } else {
@@ -1734,9 +1763,12 @@ void COutput::SetVolumeOutputValue(const string& name, unsigned long iPoint, su2
17341763 } else {
17351764
17361765 /* --- Use the offset cache for the access ---*/
1737-
17381766 const short Offset = fieldIndexCache[cachePosition++];
1739- if (Offset != -1 ){
1767+ if (Offset != -1 ) {
1768+ if (contains == true ) {
1769+ const short OffsetCompact = volumeOutput_Map.at (name).offsetCompact ;
1770+ volumeDataSorterCompact->SetUnsortedData (iPoint, OffsetCompact, value);
1771+ }
17401772 volumeDataSorter->SetUnsortedData (iPoint, Offset, value);
17411773 }
17421774 if (cachePosition == fieldIndexCache.size ()){
0 commit comments