diff --git a/.integrated_tests.yaml b/.integrated_tests.yaml index 71364ebb802..94c95c593c7 100644 --- a/.integrated_tests.yaml +++ b/.integrated_tests.yaml @@ -1,7 +1,6 @@ baselines: bucket: geosx - baseline: integratedTests/baseline_integratedTests-pr3374-8621-bbb3cb2 - + baseline: integratedTests/baseline_integratedTests-pr3434-8663-1be8ad2 allow_fail: all: '' streak: '' diff --git a/BASELINE_NOTES.md b/BASELINE_NOTES.md index 3af18f0dec8..5c416ca2820 100644 --- a/BASELINE_NOTES.md +++ b/BASELINE_NOTES.md @@ -6,6 +6,10 @@ This file is designed to track changes to the integrated test baselines. Any developer who updates the baseline ID in the .integrated_tests.yaml file is expected to create an entry in this file with the pull request number, date, and their justification for rebaselining. These notes should be in reverse-chronological order, and use the following time format: (YYYY-MM-DD). +PR #3434 (2024-11-09) +===================== +Bugfix: Fixed output of ArrayOfArray objects to restart files. + PR #3374 (2024-11-09) ==================== Bugfix for gravity treatment in flux for thermal. diff --git a/src/coreComponents/dataRepository/wrapperHelpers.hpp b/src/coreComponents/dataRepository/wrapperHelpers.hpp index 021dbf018e3..fcbaea7ab97 100644 --- a/src/coreComponents/dataRepository/wrapperHelpers.hpp +++ b/src/coreComponents/dataRepository/wrapperHelpers.hpp @@ -490,6 +490,133 @@ pullDataFromConduitNode( Array< T, NDIM, PERMUTATION > & var, std::memcpy( var.data(), valuesNode.data_ptr(), numBytesFromArray ); } + + +template< typename T, typename INDEX_TYPE > +std::enable_if_t< bufferOps::can_memcpy< T > > +pushDataToConduitNode( ArrayOfArrays< T, INDEX_TYPE > const & var2, + conduit::Node & node ) +{ + ArrayOfArraysView< T const, INDEX_TYPE > const & var = var2.toViewConst(); + internal::logOutputType( LvArray::system::demangleType( var ), "Output array via external pointer: " ); + + // ArrayOfArrays::m_numArrays + INDEX_TYPE const numArrays = var.size(); + conduit::DataType const numArraysType( conduitTypeInfo< INDEX_TYPE >::id, 1 ); + node[ "__numberOfArrays__" ].set( numArraysType, const_cast< void * >( static_cast< void const * >(&numArrays) ) ); + + // ArrayOfArrays::m_offsets + INDEX_TYPE const * const offsets = var.getOffsets(); + conduit::DataType const offsetsType( conduitTypeInfo< INDEX_TYPE >::id, numArrays+1 ); + node[ "__offsets__" ].set_external( offsetsType, const_cast< void * >( static_cast< void const * >( offsets ) ) ); + + // ArrayOfArrays::m_sizes + INDEX_TYPE const * const sizes = var.getSizes(); + conduit::DataType const sizesType( conduitTypeInfo< INDEX_TYPE >::id, numArrays ); + node[ "__sizes__" ].set_external( sizesType, const_cast< void * >( static_cast< void const * >( sizes ) ) ); + + // **** WARNING: alters the uninitialized values in the ArrayOfArrays **** + T * const values = const_cast< T * >(var.getValues()); + for( INDEX_TYPE i = 0; i < numArrays; ++i ) + { + INDEX_TYPE const curOffset = offsets[ i ]; + INDEX_TYPE const nextOffset = offsets[ i + 1 ]; + for( INDEX_TYPE j = curOffset + var.sizeOfArray( i ); j < nextOffset; ++j ) + { + if constexpr ( std::is_arithmetic< T >::value ) + { + values[ j ] = 0; + } + else + { + values[ j ] = T(); + } + } + } + + constexpr int conduitTypeID = conduitTypeInfo< T >::id; + constexpr int sizeofConduitType = conduitTypeInfo< T >::sizeOfConduitType; + conduit::DataType const dtype( conduitTypeID, offsets[numArrays] * sizeof( T ) / sizeofConduitType ); + + // Push the data into conduit + node[ "__values__" ].set_external( dtype, values ); +} + +template< typename T, typename INDEX_TYPE > +std::enable_if_t< bufferOps::can_memcpy< T > > +pullDataFromConduitNode( ArrayOfArrays< T, INDEX_TYPE > & var, + conduit::Node const & node ) +{ + + // numArrays node + conduit::Node const & numArraysNode = node.fetch_existing( "__numberOfArrays__" ); + INDEX_TYPE const * const numArrays = numArraysNode.value(); + + // offsets node + conduit::Node const & offsetsNode = node.fetch_existing( "__offsets__" ); + conduit::DataType const & offsetsDataType = offsetsNode.dtype(); + INDEX_TYPE const * const offsets = offsetsNode.value(); + INDEX_TYPE const sizeOffsets = offsetsDataType.number_of_elements(); + + // sizes node + conduit::Node const & sizesNode = node.fetch_existing( "__sizes__" ); + conduit::DataType const & sizesDataType = sizesNode.dtype(); + INDEX_TYPE const * const sizes = sizesNode.value(); + INDEX_TYPE const sizeSizes = sizesDataType.number_of_elements(); + + // Check that the numArrays, sizes and offsets are consistent. + GEOS_ERROR_IF_NE( *numArrays, sizeSizes ); + GEOS_ERROR_IF_NE( *numArrays+1, sizeOffsets ); + + // values node + conduit::Node const & valuesNode = node.fetch_existing( "__values__" ); + conduit::DataType const & valuesDataType = valuesNode.dtype(); + const INDEX_TYPE valuesSize = valuesDataType.number_of_elements(); + + // should preallocate var.m_values with estimated sizes + INDEX_TYPE const arraySizeEstimate = (*numArrays)==0 ? 0 : valuesSize / (*numArrays); + var.resize( *numArrays, arraySizeEstimate ); + var.reserveValues( valuesSize ); + + // correctly set the sizes and capacities of each sub-array + localIndex allocatedSize = 0; + for( INDEX_TYPE i = 0; i < *numArrays; ++i ) + { + INDEX_TYPE const arrayAllocation = offsets[i+1] - offsets[i]; + var.setCapacityOfArray( i, arrayAllocation ); + var.resizeArray( i, sizes[ i ] ); + allocatedSize += arrayAllocation; + } + + // make sure that the allocated size is the same as the number of values read + GEOS_ERROR_IF_NE( valuesSize, allocatedSize ); + + // make sure the allocatedSize is consistent wit the last offset + GEOS_ERROR_IF_NE( allocatedSize, offsets[sizeOffsets-1] ); + + // get a view because the ArrayOfArraysView data accessors are protected + ArrayOfArraysView< T const, INDEX_TYPE > const & varView = var.toViewConst(); + INDEX_TYPE const * const varOffsets = varView.getOffsets(); + INDEX_TYPE const * const varSizes = varView.getSizes(); + + // check that the offsets that are read are the same as the ones that were allocated + GEOS_ERROR_IF_NE( varOffsets[0], offsets[0] ); + + // check each subarray has the identical capacity and size + for( INDEX_TYPE i = 0; i<*numArrays; ++i ) + { + GEOS_ERROR_IF_NE( varOffsets[i+1], offsets[i+1] ); + GEOS_ERROR_IF_NE( varSizes[i], sizes[i] ); + } + + // copy the values + localIndex numBytesFromArray = allocatedSize * sizeof( T ); + GEOS_ERROR_IF_NE( numBytesFromArray, valuesDataType.strided_bytes() ); + std::memcpy( const_cast< T * >(varView.getValues()), valuesNode.data_ptr(), numBytesFromArray ); +} + + + template< typename T > void pushDataToConduitNode( InterObjectRelation< T > const & var, conduit::Node & node ) diff --git a/src/coreComponents/schema/schema.xsd b/src/coreComponents/schema/schema.xsd index 6150e54825e..fa48a1f1975 100644 --- a/src/coreComponents/schema/schema.xsd +++ b/src/coreComponents/schema/schema.xsd @@ -965,7 +965,7 @@ - + @@ -2325,12 +2325,16 @@ Level 0 outputs no specific information for this solver. Higher levels require m + + + + @@ -2406,12 +2410,16 @@ Level 0 outputs no specific information for this solver. Higher levels require m + + + + @@ -2477,12 +2485,16 @@ Level 0 outputs no specific information for this solver. Higher levels require m + + + + @@ -2934,12 +2946,16 @@ Level 0 outputs no specific information for this solver. Higher levels require m + + + + @@ -3009,12 +3025,16 @@ Level 0 outputs no specific information for this solver. Higher levels require m + + + + @@ -3130,7 +3150,7 @@ Level 0 outputs no specific information for this solver. Higher levels require m - + @@ -3153,7 +3173,7 @@ Local- Add jump stabilization on interior of macro elements--> - + @@ -3427,18 +3447,31 @@ Level 0 outputs no specific information for this solver. Higher levels require m + + - + - - + + @@ -6054,6 +6087,16 @@ If you want to do a three-phase simulation, please use instead wettingIntermedia + + + + + + + + + + diff --git a/src/coreComponents/schema/schema.xsd.other b/src/coreComponents/schema/schema.xsd.other index 3a9252a6e69..13a5b5ed3b9 100644 --- a/src/coreComponents/schema/schema.xsd.other +++ b/src/coreComponents/schema/schema.xsd.other @@ -471,7 +471,7 @@ - + @@ -555,7 +555,7 @@ - + @@ -592,7 +592,7 @@ - + @@ -615,8 +615,8 @@ - - + + @@ -643,7 +643,7 @@ - + @@ -662,8 +662,8 @@ - - + + @@ -684,7 +684,7 @@ - + @@ -703,8 +703,8 @@ - - + + @@ -717,7 +717,7 @@ - + @@ -728,7 +728,7 @@ - + @@ -741,7 +741,7 @@ - + @@ -754,7 +754,7 @@ - + @@ -770,7 +770,7 @@ - + @@ -804,7 +804,7 @@ - + @@ -837,8 +837,8 @@ - - + + @@ -867,7 +867,7 @@ - + @@ -884,8 +884,8 @@ - - + + @@ -898,7 +898,7 @@ - + @@ -911,7 +911,7 @@ - + @@ -924,7 +924,7 @@ - + @@ -937,7 +937,7 @@ - + @@ -950,7 +950,7 @@ - + @@ -965,7 +965,7 @@ - + @@ -976,7 +976,7 @@ - + @@ -989,7 +989,7 @@ - + @@ -1000,7 +1000,7 @@ - + @@ -1008,8 +1008,6 @@ - - @@ -1024,7 +1022,7 @@ - + @@ -1037,7 +1035,7 @@ - + @@ -1048,7 +1046,7 @@ - + @@ -1059,7 +1057,7 @@ - + @@ -1072,7 +1070,7 @@ - + @@ -1087,7 +1085,7 @@ - + @@ -1102,7 +1100,7 @@ - + @@ -1115,7 +1113,7 @@ - + @@ -1130,7 +1128,7 @@ - + @@ -1141,7 +1139,7 @@ - + @@ -1154,7 +1152,7 @@ - + @@ -1167,7 +1165,7 @@ - + @@ -1182,7 +1180,7 @@ - + @@ -1198,7 +1196,7 @@ - + @@ -1213,7 +1211,7 @@ - + @@ -1230,7 +1228,7 @@ - + @@ -1247,7 +1245,7 @@ - + @@ -1262,7 +1260,7 @@ - + @@ -1275,7 +1273,7 @@ - + @@ -1314,7 +1312,7 @@ - + @@ -1343,7 +1341,7 @@ - + @@ -1436,7 +1434,7 @@ - + @@ -2587,7 +2585,20 @@ - + + + + + + + + + + + + + + @@ -2992,7 +3003,7 @@ - + @@ -3020,7 +3031,7 @@ - + @@ -3039,11 +3050,11 @@ - + - + @@ -3053,7 +3064,7 @@ - + @@ -3063,11 +3074,11 @@ - + - + @@ -3077,7 +3088,7 @@ - + @@ -3087,7 +3098,7 @@ - + @@ -3097,7 +3108,7 @@ - + @@ -3121,7 +3132,7 @@ - + @@ -3139,7 +3150,7 @@ - + @@ -3151,7 +3162,7 @@ - + @@ -3163,7 +3174,7 @@ - + @@ -3171,11 +3182,11 @@ - + - + @@ -3198,7 +3209,7 @@ - + @@ -3224,7 +3235,7 @@ - + @@ -3245,7 +3256,7 @@ - + @@ -3275,7 +3286,7 @@ - + @@ -3289,7 +3300,7 @@ - + @@ -3316,7 +3327,7 @@ - + @@ -3355,7 +3366,7 @@ - +