Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/corbett/layouts #633

Merged
merged 5 commits into from
Nov 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions examples/advanced_xml_features/included/included_b.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<PeriodicEvent name="restarts"
timeFrequency="1e4"
targetExactTimestep="0"
target="/Outputs/sidreRestart"/>
target="/Outputs/restartOutput"/>

</Events>

Expand Down Expand Up @@ -48,6 +48,6 @@

<Outputs>
<Silo name="siloOutput"/>
<Restart name="sidreRestart"/>
<Restart name="restartOutput"/>
</Outputs>
</Problem>
</Problem>
6 changes: 3 additions & 3 deletions examples/advanced_xml_features/parameters_example.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ XML Units:
<PeriodicEvent name="restarts"
timeFrequency="1e4"
targetExactTimestep="0"
target="/Outputs/sidreRestart"/>
target="/Outputs/restartOutput"/>

</Events>

Expand Down Expand Up @@ -103,7 +103,7 @@ XML Units:

<Outputs>
<Silo name="siloOutput"/>
<Restart name="sidreRestart"/>
<Restart name="restartOutput"/>
</Outputs>

<FieldSpecifications>
Expand Down Expand Up @@ -156,4 +156,4 @@ XML Units:
scale="5e6"
setNames="{sink}"/>
</FieldSpecifications>
</Problem>
</Problem>
6 changes: 3 additions & 3 deletions examples/advanced_xml_features/symbolic_math_example.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ XML Symbolic Math:
<PeriodicEvent name="restarts"
timeFrequency="1e4"
targetExactTimestep="0"
target="/Outputs/sidreRestart"/>
target="/Outputs/restartOutput"/>

</Events>

Expand Down Expand Up @@ -115,7 +115,7 @@ XML Symbolic Math:

<Outputs>
<Silo name="siloOutput"/>
<Restart name="sidreRestart"/>
<Restart name="restartOutput"/>
</Outputs>

<FieldSpecifications>
Expand Down Expand Up @@ -168,4 +168,4 @@ XML Symbolic Math:
scale="5e6"
setNames="{sink}"/>
</FieldSpecifications>
</Problem>
</Problem>
4 changes: 2 additions & 2 deletions examples/event_examples.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
that will cause it to be triggered at a time equal to a multiple of timeFrequency -->
<PeriodicEvent name="periodic_c"
timeFrequency="5"
target="/Outputs/sidreRestart"/>
target="/Outputs/restartOutput"/>

<!-- This event will execute every 3 cycles. When it does, it will attempt to
execute each of its two sub-events -->
Expand Down Expand Up @@ -77,7 +77,7 @@


<Outputs>
<Restart name="sidreRestart"/>
<Restart name="restartOutput"/>
</Outputs>


Expand Down
2 changes: 1 addition & 1 deletion integratedTests
227 changes: 141 additions & 86 deletions src/coreComponents/codingUtilities/GeosxTraits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,119 +29,174 @@ namespace geosx
namespace traits
{

template <class T>
constexpr bool is_string = is_instance_of_v<std::string, T>;

template <class T>
constexpr bool is_std_vector = is_instantiation_of_v<std::vector, T>;

template <class T>
constexpr bool is_pair = is_instantiation_of_v<std::pair, T>;

template <class T>
constexpr bool is_map = is_instantiation_of_v<mapBase, T>;

template <class T>
constexpr bool is_set = is_instantiation_of_v<LvArray::SortedArray, T>;

template<typename>
constexpr bool is_array = false;

template< typename T, int NDIM, typename INDEX_TYPE >
constexpr bool is_array< LvArray::Array<T,NDIM,INDEX_TYPE> > = true;

template <class T>
constexpr bool is_tensorT = is_instance_of_v<R1Tensor, T> ||
is_instance_of_v<R2Tensor, T> ||
is_instance_of_v<R2SymTensor, T>;

} /* namespace traits */



namespace bufferOps
namespace internal
{
HAS_ALIAS( value_type )

HAS_ALIAS( pointer )

template< class T,
bool HASPOINTERTYPE = has_alias_pointer< T >::value >
struct PointerHelper
{
using Pointer = T *;
using ConstPointer = T const *;
};

template< class T >
struct PointerHelper< T, true >
{
using Pointer = typename T::pointer;
using ConstPointer = typename T::const_pointer;
};

template< typename T >
struct has_data_method
{
HAS_MEMBER_FUNCTION_VARIANT( data, nonconst, typename PointerHelper< T >::Pointer, , , )
HAS_MEMBER_FUNCTION_VARIANT( data, const, typename PointerHelper< T >::Pointer, const, , )

static constexpr bool value = has_memberfunction_vnonconst_data< T >::value ||
has_memberfunction_vconst_data< T >::value;
};

template< typename T >
struct has_chai_move_method
{
HAS_MEMBER_FUNCTION( move,
void,
,
VA_LIST( chai::ExecutionSpace, bool ),
VA_LIST( chai::CPU, true ) )
static constexpr bool value = has_memberfunction_move< T >::value;
};

template< typename T >
struct has_empty_method
{
HAS_MEMBER_FUNCTION( empty, bool, const, , )
static constexpr bool value = has_memberfunction_empty< T >::value;
};

template< typename T, typename INDEX_TYPE >
struct has_size_method
{
HAS_MEMBER_FUNCTION( size, INDEX_TYPE, const, , )
static constexpr bool value = has_memberfunction_size< T >::value;
};

template< typename T, typename INDEX_TYPE >
struct has_dimension_size_method
{
HAS_MEMBER_FUNCTION( size, INDEX_TYPE, const, VA_LIST( int ), VA_LIST( 0 ) )
static constexpr bool value = has_memberfunction_size< T >::value;
};

template< typename T, typename INDEX_TYPE >
struct has_resize_method
{
HAS_MEMBER_FUNCTION( resize, void, , VA_LIST( INDEX_TYPE ), VA_LIST( INDEX_TYPE( 0 ) ) )
static constexpr bool value = has_memberfunction_resize< T >::value;
};

template< typename T, typename DVT, typename INDEX_TYPE >
struct has_resize_default_method
{
HAS_MEMBER_FUNCTION( resizeDefault, void, , VA_LIST( INDEX_TYPE, DVT const & ), VA_LIST( INDEX_TYPE( 0 ), std::declval< DVT const & >() ) )
static constexpr bool value = has_memberfunction_resizeDefault< T >::value;
};

template< typename T >
struct has_resize_dimensions_method
{
HAS_MEMBER_FUNCTION( resize, void, , VA_LIST( int, localIndex const * ),
VA_LIST( 0, static_cast< localIndex const * >( nullptr ) ) )
static constexpr bool value = has_memberfunction_resize< T >::value;
};


} // namespace internal

/* Forward declaration of is_packable */
template< typename T >
struct is_packable;

using Pointer = typename internal::PointerHelper< T >::Pointer;

template< typename T >
struct is_noncontainer_type_packable
{
static constexpr bool value = std::is_trivial<T>::value ||
std::is_arithmetic<T>::value ||
traits::is_tensorT<T> ||
traits::is_string<T>;
};
template< typename T >
constexpr bool is_noncontainer_type_packable<T>::value;

template<typename>
struct is_packable_array : std::false_type {};
using ConstPointer = typename internal::PointerHelper< T >::ConstPointer;

template<typename T, int NDIM, typename INDEX_TYPE>
struct is_packable_array< LvArray::Array<T,NDIM,INDEX_TYPE> > : is_packable<T> {};
template< typename T >
constexpr bool has_alias_value_type = internal::has_alias_value_type< T >::value;

template<typename T, int NDIM, typename INDEX_TYPE>
struct is_packable_array< LvArray::ArrayView<T,NDIM,INDEX_TYPE> > : is_packable<T> {};
template< typename T >
constexpr bool has_data_method = internal::has_data_method< T >::value;

template<typename T, int NDIM, typename INDEX_TYPE>
struct is_packable_array< LvArray::ArraySlice<T,NDIM,INDEX_TYPE> > : is_packable<T> {};
template< typename T >
constexpr bool has_chai_move_method = internal::has_chai_move_method< T >::value;

template<typename T, typename INDEX_TYPE>
struct is_packable_array< LvArray::ArrayOfArrays<T,INDEX_TYPE> > : is_packable<T> {};
template< typename T >
constexpr bool has_empty_method = internal::has_empty_method< T >::value;

template< typename T >
constexpr bool has_size_method = internal::has_size_method< T, int >::value ||
internal::has_size_method< T, unsigned int >::value ||
internal::has_size_method< T, long >::value ||
internal::has_size_method< T, unsigned long >::value ||
internal::has_size_method< T, long long >::value ||
internal::has_size_method< T, unsigned long long >::value;

template<typename>
struct is_packable_set : std::false_type {};
template< typename T >
constexpr bool has_dimension_size_method = internal::has_dimension_size_method< T, int >::value ||
internal::has_dimension_size_method< T, unsigned int >::value ||
internal::has_dimension_size_method< T, long >::value ||
internal::has_dimension_size_method< T, unsigned long >::value ||
internal::has_dimension_size_method< T, long long >::value ||
internal::has_dimension_size_method< T, unsigned long long >::value;

template< typename T >
struct is_packable_set< set<T> >
{
static constexpr bool value = is_packable<T>::value;
};
template< typename T>
constexpr bool is_packable_set< set<T> >::value;
constexpr bool has_resize_method = internal::has_resize_method< T, int >::value ||
internal::has_resize_method< T, unsigned int >::value ||
internal::has_resize_method< T, long >::value ||
internal::has_resize_method< T, unsigned long >::value ||
internal::has_resize_method< T, long long >::value ||
internal::has_resize_method< T, unsigned long long >::value;

template< typename T, typename DVT >
constexpr bool has_resize_default_method = internal::has_resize_default_method< T, DVT, int >::value ||
internal::has_resize_default_method< T, DVT, unsigned int >::value ||
internal::has_resize_default_method< T, DVT, long >::value ||
internal::has_resize_default_method< T, DVT, unsigned long >::value ||
internal::has_resize_default_method< T, DVT, long long >::value ||
internal::has_resize_default_method< T, DVT, unsigned long long >::value;

template< typename T >
constexpr bool has_resize_default_method< T, void > = false;

template<typename>
struct is_packable_map : std::false_type {};
template< typename T >
constexpr bool has_resize_dimensions_method = internal::has_resize_dimensions_method< T >::value;

template<typename T_KEY, typename T_VAL, typename SORTED>
struct is_packable_map< mapBase<T_KEY, T_VAL, SORTED> >
{
static constexpr bool value = is_packable<T_KEY>::value &&
is_packable<T_VAL>::value;
};
template< typename T_KEY, typename T_VAL, typename SORTED>
constexpr bool is_packable_map< mapBase<T_KEY, T_VAL, SORTED> >::value;
template< typename T >
constexpr bool is_string = is_instance_of_v< std::string, T >;

template< typename T >
constexpr bool is_std_vector = is_instantiation_of_v< std::vector, T >;

template< typename T >
struct is_packable
{
static constexpr bool value = is_noncontainer_type_packable<T>::value ||
is_packable_array<T>::value ||
is_packable_map<T>::value ||
is_packable_set<T>::value ;
constexpr bool is_pair = is_instantiation_of_v< std::pair, T >;

};
template< typename T >
constexpr bool is_packable<T>::value;
constexpr bool is_map = is_instantiation_of_v< mapBase, T >;

template< typename T >
constexpr bool is_set = is_instantiation_of_v< LvArray::SortedArray, T >;

template< typename T >
struct is_packable_by_index
{
static constexpr bool value = is_packable_array<T>::value ;
constexpr bool is_array = LvArray::isArray< T >;

};
template< typename T >
constexpr bool is_packable_by_index<T>::value;
constexpr bool is_tensorT = is_instance_of_v< R1Tensor, T > ||
is_instance_of_v< R2Tensor, T > ||
is_instance_of_v< R2SymTensor, T >;

} /* namespace bufferOps */
} /* namespace traits */

template<typename T, bool COND>
struct add_const_if
Expand Down
Loading