19template<
typename ValueType>
29 field.
exec(),
dsl::Coeff(1.0), field, termType
35 const scalar dtInver = 1.0 / dt;
36 const auto vol = this->
getField().mesh().cellVolumes().span();
38 auto [sourceSpan, field, oldField] =
44 KOKKOS_LAMBDA(
const size_t celli) {
45 sourceSpan[celli] += dtInver * (field[celli] - oldField[celli]) * vol[celli];
52 const scalar dtInver = 1.0 / dt;
53 const auto vol = this->
getField().mesh().cellVolumes().span();
55 const auto [diagOffs, oldField] =
57 auto [values, cols, rows] = ls.
matrix().span().span();
58 auto rhs = ls.
rhs().span();
63 KOKKOS_LAMBDA(
const size_t celli) {
64 std::size_t idx = rows[celli] + diagOffs[celli];
65 const auto commonCoef = operatorScaling[celli] * vol[celli] * dtInver;
66 values[idx] += commonCoef * one<ValueType>();
67 rhs[celli] += commonCoef * oldField[celli];
75 auto [A, b, sp] = ls.
view();
76 const auto&
exec = A.exec();
94 std::string
getName()
const {
return "DdtOperator"; }
99 const std::shared_ptr<SparsityPattern> sparsityPattern_;
A class to contain the data and executors for a field and define some basic operations.
std::pair< size_t, size_t > range() const
Gets the range of the field.
const Executor & exec() const
Gets the executor associated with the field.
OperatorMixin(const Executor exec, const Coeff &coeffs, VolumeField< ValueType > &field, Operator::Type type)
virtual const Executor & exec() const final
VolumeField< ValueType > & getField()
VolumeField< ValueType > & field_
la::LinearSystem< ValueType, localIdx > createEmptyLinearSystem() const
void implicitOperation(la::LinearSystem< ValueType, localIdx > &ls, scalar t, scalar dt)
DdtOperator(dsl::Operator::Type termType, VolumeField< ValueType > &field)
std::string getName() const
void explicitOperation(Field< ValueType > &source, scalar t, scalar dt)
void build(const Input &input)
Represents a volume field in a finite volume method.
A class representing a linear system of equations.
const Executor & exec() const
LinearSystemView< ValueType, IndexType > view()
Field< ValueType > & rhs()
std::string sparsityPattern() const
CSRMatrix< ValueType, IndexType > & matrix()
FieldType & oldTime(FieldType &field)
Retrieves the old time field of a given field.
std::variant< Dictionary, TokenList > Input
void parallelFor(const Executor &exec, std::pair< size_t, size_t > range, Kernel kernel)
auto spans(Args &... fields)