fill
¶
Header: "NeoFOAM/fields/fieldFreeFunctions.hpp"
Description¶
The function fill
fills the entire field with a given value or a subfield with a given value if a range is defined.
Definition¶
-
template<typename ValueType>
void NeoFOAM::fill(Field<ValueType> &a, const std::type_identity_t<ValueType> value, std::pair<size_t, size_t> range = {0, 0})¶ Fill the field with a scalar value using a specific executor.
- Parameters:
field – The field to fill.
value – The scalar value to fill the field with.
range – The range to fill the field in. If not provided, the whole field is filled.
Example¶
// or any other executor CPUExecutor, SerialExecutor
NeoFOAM::Executor = NeoFOAM::GPUExecutor{};
NeoFOAM::Field<NeoFOAM::scalar> field(exec, 2);
NeoFOAM::fill(field, 1.0);
NeoFOAM::fill(field, 2.0, {1, 2}); // fill a subfield with a value
// copy to host
auto hostField = field.copyToHost();
for (auto i = 0; i < field.size(); ++i)
{
std::cout << hostField[i] << std::endl;
}
// prints:
// 1.0
// 2.0