Files
MeanField_SERiF/src/include/serif/discretization/blocks/base.hpp

84 lines
2.7 KiB
C++
Raw Normal View History

#pragma once
2026-10-01 15:12:07 -04:00
/**
* @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;
2026-10-01 15:12:07 -04:00
/**
* @struct block
* @brief Base class for all block types in the discretization framework.
*/
struct block {};
2026-10-01 15:12:07 -04:00
/**
* @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;
};
2026-10-01 15:12:07 -04:00
/**
* @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;
};
2026-10-01 15:12:07 -04:00
/**
* @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);
};
2026-10-01 15:12:07 -04:00
/**
* @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);
};
2026-10-01 15:12:07 -04:00
/**
* @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;
}
};
2026-10-01 15:12:07 -04:00
/**
* @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;
}
};
}