From 6436f3f3bb26286a5a42713c2e4a5714a2a71a85 Mon Sep 17 00:00:00 2001 From: Gregor Olenik Date: Thu, 10 Oct 2024 17:06:04 +0200 Subject: [PATCH] update class names --- doc/DSL/{eqnSystem.rst => equation.rst} | 35 +++++++++++---------- doc/DSL/index.rst | 6 ++-- doc/DSL/{eqnTerm.rst => operator.rst} | 41 ++++++++++++------------- 3 files changed, 41 insertions(+), 41 deletions(-) rename doc/DSL/{eqnSystem.rst => equation.rst} (55%) rename doc/DSL/{eqnTerm.rst => operator.rst} (58%) diff --git a/doc/DSL/eqnSystem.rst b/doc/DSL/equation.rst similarity index 55% rename from doc/DSL/eqnSystem.rst rename to doc/DSL/equation.rst index 2b865381f..1a059d01b 100644 --- a/doc/DSL/eqnSystem.rst +++ b/doc/DSL/equation.rst @@ -1,8 +1,9 @@ -EqnSystem +Equation --------- -The `EqnSystem` template class in NeoFOAM holds, manages, builds and solves the expressed/programmed equation and its core responsibilities lie in the answering of the following questions: +The `Equation` class in NeoFOAM holds, manages, builds and solves the expressed/programmed equation. +Its core responsibility lie in the answering of the following questions: - How to discretize the spatial terms? - In OpenFOAM this information is provided in **fvSchemes** @@ -12,22 +13,22 @@ The `EqnSystem` template class in NeoFOAM holds, manages, builds and solves the - In OpenFOAM this information is provided in **fvSolution** The main difference between NeoFOAM and OpenFOAM is that the DSL is evaluated lazily, i.e. evaluation is not performed on construction by default. -Since, the evaluation is not tied to the construction but rather delayde, other numerical integration strategies (e.g. RK methods or even substepping within an the equation) are possible. +Since, the evaluation is not tied to the construction but rather delayed, other numerical integration strategies (e.g. RK methods or even sub-stepping within an the equation) are possible. -To implement lazy evaluation, the `EqnSystem` stores 3 vectors: +To implement lazy evaluation, the `Equation` stores 3 vectors: .. mermaid:: classDiagram - class EqnTerm { + class Operator { +explicitOperation(...) +implicitOperation(...) } - class DivEqnTerm { + class DivOperator { +explicitOperation(...) +implicitOperation(...) } - class TemporalEqnTerm { + class TemporalOperator { +explicitOperation(...) +implicitOperation(...) } @@ -35,15 +36,15 @@ To implement lazy evaluation, the `EqnSystem` stores 3 vectors: +explicitOperation(...) +implicitOperation(...) } - class EqnSystem { - +temporalTerms_: vector~EqnTerm~ - +implicitTerms_: vector~EqnTerm~ - +explicitTerms_: vector~EqnTerm~ + class Equation { + +temporalTerms_: vector~Operator~ + +implicitTerms_: vector~Operator~ + +explicitTerms_: vector~Operator~ } - EqnTerm <|-- DivEqnTerm - EqnTerm <|-- TemporalEqnTerm - EqnTerm <|-- Others - EqnSystem <|-- EqnTerm + Operator <|-- DivOperator + Operator <|-- TemporalOperator + Operator <|-- Others + Equation <|-- Operator -Thus, an `EqnSystem` consists of multiple `EqnTerms` which are either explicit, implicit, or temporal. -Consequently, addition, subtraction, and scaling with a field needs to be handled by the `EqnTerm`. +Thus, an `Equation` consists of multiple `Operators` which are either explicit, implicit, or temporal. +Consequently, addition, subtraction, and scaling with a field needs to be handled by the `Operator`. diff --git a/doc/DSL/index.rst b/doc/DSL/index.rst index a193a40ed..840f7712f 100644 --- a/doc/DSL/index.rst +++ b/doc/DSL/index.rst @@ -46,7 +46,7 @@ The NeoFOAM DSL is designed as drop in replacement for OpenFOAM DSL and the adop .. code-block:: cpp - dsl::EqnSystem UEqn + dsl::Equation UEqn ( fvcc::impOp::ddt(U) + fvcc::impOp::div(phi, U) @@ -67,5 +67,5 @@ After the system is assembled or solved, it provides access to the linear system :maxdepth: 2 :glob: - eqnSystem.rst - eqnTerm.rst + equation.rst + operator.rst diff --git a/doc/DSL/eqnTerm.rst b/doc/DSL/operator.rst similarity index 58% rename from doc/DSL/eqnTerm.rst rename to doc/DSL/operator.rst index c9ddc2e66..30c0d3c15 100644 --- a/doc/DSL/eqnTerm.rst +++ b/doc/DSL/operator.rst @@ -1,44 +1,43 @@ -EqnTerm +Operator ======= -The template `EqnTerm` represents a term in an equation and can be instantiated with different value types. -An `EqnTerm` is either explicit, implicit or temporal, and needs to be scalable by a scalar value or a further field. -The `EqnTerm` implementation uses Type Erasure (more details `[1] `_ `[2] `_ `[3] `_) to achieve polymorphism without inheritance. Consequently, the class needs only to implement the interface which is used in the DSL and which is shown in the below example: - +The `Operator` class represents a term in an equation and can be instantiated with different value types. +An `Operator` is either explicit, implicit or temporal, and can be scalable by a an additional coefficient, for example a scalar value or a further field. +The `Operator` implementation uses Type Erasure (more details `[1] `_ `[2] `_ `[3] `_) to achieve polymorphism without inheritance. Consequently, the class needs only to implement the interface which is used in the DSL and which is shown in the below example: Example: .. code-block:: cpp - NeoFOAM::DSL::EqnTerm divTerm = - Divergence(NeoFOAM::DSL::EqnTerm::Type::Explicit, exec, ...); + NeoFOAM::DSL::Operator divTerm = + Divergence(NeoFOAM::DSL::Operator::Type::Explicit, exec, ...); - NeoFOAM::DSL::EqnTerm ddtTerm = - TimeTerm(NeoFOAM::DSL::EqnTerm::Type::Temporal, exec, ..); + NeoFOAM::DSL::Operator ddtTerm = + TimeTerm(NeoFOAM::DSL::Operator::Type::Temporal, exec, ..); -To fit the specification of the EqnSystem (storage in a vector), the EqnTerm needs to be able to be scaled: +To fit the specification of the EqnSystem (storage in a vector), the Operator needs to be able to be scaled: .. code-block:: cpp NeoFOAM::Field scalingField(exec, nCells, 2.0); auto sF = scalingField.span(); - dsl::EqnTerm customTerm = - CustomTerm(dsl::EqnTerm::Type::Explicit, exec, nCells, 1.0); + dsl::Operator customTerm = + CustomTerm(dsl::Operator::Type::Explicit, exec, nCells, 1.0); auto constantScaledTerm = 2.0 * customTerm; // A constant scaling factor of 2 for the term. auto fieldScaledTerm = scalingField * customTerm; // scalingField is used to scale the term. - // EqnTerm also supports a similar syntax as OpenFOAM + // Operator also supports a similar syntax as OpenFOAM auto multiScaledTerm = (scale + scale + scale + scale) * customTerm; - // EqnTerm also supports the use of a lambda as scaling function to reduce the number of temporaries generated + // Operator also supports the use of a lambda as scaling function to reduce the number of temporaries generated auto lambdaScaledTerm = (KOKKOS_LAMBDA(const NeoFOAM::size_t i) { return sF[i] + sF[i] + sF[i] + sF[i]; }) * customTerm; -To add a user-defined `EqnTerm`, a new derived class must be created, inheriting from `EqnTermMixin`, - and provide the definitions of the below virtual functions that are required for the `EqnTerm` interface: +To add a user-defined `Operator`, a new derived class must be created, inheriting from `OperatorMixin`, + and provide the definitions of the below virtual functions that are required for the `Operator` interface: - build: build the term - explicitOperation: perform the explicit operation @@ -53,7 +52,7 @@ An example is given below: .. code-block:: cpp - class CustomEqnTerm : public dsl::EqnTermMixin + class CustomOperator : public dsl::OperatorMixin { public: @@ -75,7 +74,7 @@ An example is given below: void explicitOperation(NeoFOAM::Field& source) { NeoFOAM::scalar setValue = value; - // scaleField is defined in EqnTermMixin + // scaleField is defined in OperatorMixin // and accounts for the scaling of the terms // and considers scaling by fields and scalars auto scale = scaleField(); @@ -88,7 +87,7 @@ An example is given below: } // other helper functions - dsl::EqnTerm::Type getType() const { return termType_; } + dsl::Operator::Type getType() const { return termType_; } const NeoFOAM::Executor& exec() const { return exec_; } @@ -96,7 +95,7 @@ An example is given below: fvcc::VolumeField* volumeField() { return nullptr; } - dsl::EqnTerm::Type termType_; + dsl::Operator::Type termType_; const NeoFOAM::Executor exec_; @@ -104,7 +103,7 @@ An example is given below: NeoFOAM::scalar value = 1.0; }; -The required scaling of the term is handle by the `scaleField` function, provided by `EqnTermMixin`. The `scaleField` function returns the 'ScalingField' class that is used to scale by fields and scalars. +The required scaling of the term is handle by the `scaleField` function, provided by `OperatorMixin`. The `scaleField` function returns the 'ScalingField' class that is used to scale by fields and scalars. .. code-block:: cpp