95 lines
3.2 KiB
C++
95 lines
3.2 KiB
C++
#pragma once
|
|
|
|
/**
|
|
* @file base.hpp
|
|
* @author Emily M. Boudreaux
|
|
* @brief This file provides the base classes for residual and value blocks in the discretization framework.
|
|
*/
|
|
namespace serif::discretization::blocks {
|
|
inline constexpr int DYNAMIC_BLOCK_SIZE = -1;
|
|
|
|
/**
|
|
* @struct block
|
|
* @brief Base class for all block types in the discretization framework.
|
|
*/
|
|
struct block {};
|
|
|
|
/**
|
|
* @enum RepresentedValueKind
|
|
* @brief Enum representing the kind of value a block represents, either a physical quantity (value) or a residual (residual).
|
|
*
|
|
* Generally this is mostly used in the solver/normalization system.
|
|
*/
|
|
enum class RepresentedValueKind {
|
|
value, ///< A value representing a physical quantity (e.g., temperature, pressure).
|
|
residual ///< A residual representing the difference between the current state and the desired state in a numerical method.
|
|
};
|
|
|
|
/**
|
|
* @struct residual_block_base
|
|
* @brief Base class for residual blocks, derived from block.
|
|
*/
|
|
struct residual_block_base : block {
|
|
static constexpr int static_block_size = DYNAMIC_BLOCK_SIZE;
|
|
};
|
|
|
|
/**
|
|
* @struct value_block_base
|
|
* @brief Base class for value blocks, derived from block.
|
|
*/
|
|
struct value_block_base : block {
|
|
static constexpr int static_block_size = DYNAMIC_BLOCK_SIZE;
|
|
};
|
|
|
|
|
|
/**
|
|
* @struct generated_value_block
|
|
* @brief Final class for generated value blocks, derived from value_block_base. These are blocks that are generated at runtime
|
|
* @todo This may be removable at this point
|
|
*/
|
|
template <typename GeneratedValue>
|
|
struct generated_value_block final : value_block_base {
|
|
using GeneratedType = GeneratedValue;
|
|
static constexpr int static_block_size = static_cast<int>(GeneratedValue::scalarArity);
|
|
};
|
|
|
|
/**
|
|
* @struct generated_residual_block
|
|
* @brief Final class for generated residual blocks, derived from residual_block_base. These are blocks that are generated at runtime
|
|
* @todo This may be removable at this point
|
|
*/
|
|
template <typename GeneratedResidual>
|
|
struct generated_residual_block final : residual_block_base {
|
|
using GeneratedType = GeneratedResidual;
|
|
static constexpr int static_block_size = static_cast<int>(GeneratedResidual::scalarArity);
|
|
};
|
|
|
|
/**
|
|
* @struct residual_block
|
|
* @brief Final class for residual blocks with a fixed index, derived from residual_block_base.
|
|
*/
|
|
template <int index_value>
|
|
struct residual_block final : residual_block_base {
|
|
static constexpr int index = index_value;
|
|
|
|
// ReSharper disable once CppNonExplicitConversionOperator
|
|
constexpr operator int() const noexcept {
|
|
return index;
|
|
}
|
|
};
|
|
|
|
/**
|
|
* @struct value_block
|
|
* @brief Final class for value blocks with a fixed index, derived from value_block_base.
|
|
*/
|
|
template <int index_value>
|
|
struct value_block final : value_block_base {
|
|
static constexpr int index = index_value;
|
|
|
|
// ReSharper disable once CppNonExplicitConversionOperator
|
|
constexpr operator int() const noexcept {
|
|
return index;
|
|
}
|
|
};
|
|
|
|
} |