Skip to content

Commit

Permalink
reorganize, change DSL->dsl, move timeIntegration to dsl
Browse files Browse the repository at this point in the history
  • Loading branch information
greole committed Oct 11, 2024
1 parent 7d24306 commit 4791d62
Show file tree
Hide file tree
Showing 14 changed files with 38 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
// SPDX-FileCopyrightText: 2023 NeoFOAM authors
#pragma once

namespace NeoFOAM::DSL
namespace NeoFOAM::dsl
{

/**
* @class Coeff
* @brief A class that represents a coefficient for the NeoFOAM DSL.
* @brief A class that represents a coefficient for the NeoFOAM dsl.
*
* This class stores a single scalar coefficient and optionally span of values.
* It is used to delay the evaluation of a scalar multiplication with a field to
Expand Down Expand Up @@ -107,4 +107,4 @@ inline Coeff operator*(const Coeff& lhs, const Coeff& rhs)
return result;
}

} // namespace NeoFOAM::DSL
} // namespace NeoFOAM::dsl
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

#include "NeoFOAM/core/primitives/scalar.hpp"
#include "NeoFOAM/fields/field.hpp"
#include "NeoFOAM/DSL/operator.hpp"
#include "NeoFOAM/dsl/operator.hpp"
#include "NeoFOAM/core/error.hpp"

namespace NeoFOAM::DSL
namespace NeoFOAM::dsl
{

class Equation
Expand Down Expand Up @@ -189,4 +189,4 @@ Equation operator-(const Operator& lhs, const Operator& rhs)
return equation;
}

} // namespace NeoFOAM::DSL
} // namespace NeoFOAM::dsl
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,11 @@

#include "NeoFOAM/core/primitives/scalar.hpp"
#include "NeoFOAM/fields/field.hpp"
#include "NeoFOAM/core/parallelAlgorithms.hpp"
#include "NeoFOAM/finiteVolume/cellCentred/fields/volumeField.hpp"
#include "NeoFOAM/core/input.hpp"
#include "NeoFOAM/DSL/coeff.hpp"
#include "NeoFOAM/dsl/coeff.hpp"


namespace fvcc = NeoFOAM::finiteVolume::cellCentred;

namespace NeoFOAM::DSL
namespace NeoFOAM::dsl
{

template<typename T>
Expand All @@ -38,10 +34,10 @@ concept HasExplicitOperator = requires(T t) {

/* @class OperatorMixin
* @brief A mixin class to represent simplify implementations of concrete operators
* in NeoFOAMs DSL
* in NeoFOAMs dsl
*
*
* @ingroup DSL
* @ingroup dsl
*/
class OperatorMixin
{
Expand Down Expand Up @@ -70,7 +66,7 @@ class OperatorMixin


/* @class Operator
* @brief A class to represent a operator in NeoFOAMs DSL
* @brief A class to represent a operator in NeoFOAMs dsl
*
* The design here is based on the type erasure design pattern
* see https://www.youtube.com/watch?v=4eeESJQk-mw
Expand All @@ -79,7 +75,7 @@ class OperatorMixin
* of Operators e.g Divergence, Laplacian, etc can be stored in a vector of
* Operators
*
* @ingroup DSL
* @ingroup dsl
*/
class Operator
{
Expand Down Expand Up @@ -251,4 +247,4 @@ Operator operator*(CoeffFunction coeffFunc, const Operator& lhs)
return result;
}

} // namespace NeoFOAM::DSL
} // namespace NeoFOAM::dsl
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@
#include <functional>

#include "NeoFOAM/fields/field.hpp"
#include "NeoFOAM/core/executor/executor.hpp"
#include "NeoFOAM/finiteVolume/cellCentred/timeIntegration/timeIntegration.hpp"
#include "NeoFOAM/mesh/unstructured.hpp"

#include "NeoFOAM/dsl/timeIntegration/timeIntegration.hpp"

namespace NeoFOAM::finiteVolume::cellCentred
{
Expand All @@ -20,7 +17,7 @@ class ForwardEuler : public TimeIntegrationFactory::Register<ForwardEuler>

public:

ForwardEuler(const DSL::Equation& eqnSystem, const Dictionary& dict);
ForwardEuler(const dsl::Equation& eqnSystem, const Dictionary& dict);

static std::string name() { return "forwardEuler"; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
#include "NeoFOAM/core/executor/executor.hpp"
#include "NeoFOAM/mesh/unstructured.hpp"
#include "NeoFOAM/finiteVolume/cellCentred.hpp"

#include "NeoFOAM/DSL/operator.hpp"
#include "NeoFOAM/DSL/equation.hpp"
#include "NeoFOAM/dsl/operator.hpp"
#include "NeoFOAM/dsl/equation.hpp"

#include <functional>

Expand All @@ -19,14 +18,14 @@ namespace NeoFOAM
class TimeIntegrationFactory :
public RuntimeSelectionFactory<
TimeIntegrationFactory,
Parameters<const DSL::Equation&, const Dictionary&>>
Parameters<const dsl::Equation&, const Dictionary&>>
{

public:

static std::string name() { return "timeIntegrationFactory"; }

TimeIntegrationFactory(const DSL::Equation& eqnSystem, const Dictionary& dict)
TimeIntegrationFactory(const dsl::Equation& eqnSystem, const Dictionary& dict)
: eqnSystem_(eqnSystem), dict_(dict)
{}

Expand All @@ -39,7 +38,7 @@ class TimeIntegrationFactory :

protected:

DSL::Equation eqnSystem_;
dsl::Equation eqnSystem_;

const Dictionary& dict_;
};
Expand All @@ -55,7 +54,7 @@ class TimeIntegration
TimeIntegration(TimeIntegration&& timeIntegrate)
: timeIntegrateStrategy_(std::move(timeIntegrate.timeIntegrateStrategy_)) {};

TimeIntegration(const DSL::Equation& eqnSystem, const Dictionary& dict)
TimeIntegration(const dsl::Equation& eqnSystem, const Dictionary& dict)
: timeIntegrateStrategy_(
TimeIntegrationFactory::create(dict.get<std::string>("type"), eqnSystem, dict)
) {};
Expand Down
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ target_sources(
"finiteVolume/cellCentred/operators/gaussGreenDiv.cpp"
"finiteVolume/cellCentred/interpolation/linear.cpp"
"finiteVolume/cellCentred/interpolation/upwind.cpp"
"finiteVolume/cellCentred/timeIntegration/forwardEuler.cpp")
"dsl/timeIntegration/forwardEuler.cpp")

include(${CMAKE_SOURCE_DIR}/cmake/Sanitizer.cmake)
enable_sanitizers(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@

#include <memory>

#include "NeoFOAM/finiteVolume/cellCentred/timeIntegration/forwardEuler.hpp"
#include "NeoFOAM/dsl/timeIntegration/forwardEuler.hpp"
#include "NeoFOAM/core/error.hpp"
#include "NeoFOAM/core/parallelAlgorithms.hpp"

namespace NeoFOAM::finiteVolume::cellCentred
{
Expand Down
3 changes: 2 additions & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ list(APPEND CMAKE_MODULE_PATH ${Catch2_SOURCE_DIR}/extras)
# has to be first since it adds the main target
add_subdirectory(catch2)

# This function creates unit tests. It allows the following keywords:
# include "NeoFOAM/core/parallelAlgorithms.hpp" This function creates unit tests. It allows the
# following keywords:
#
# * MPI_SIZE: the number of MPI processors to be used, defaults to 1 if not set
# * COMMAND: the test command (same behavior as for CMake's add_test), defaults to the test name
Expand Down
6 changes: 3 additions & 3 deletions test/dsl/coeff.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
#include <catch2/benchmark/catch_benchmark.hpp>

#include "NeoFOAM/fields/field.hpp"
#include "NeoFOAM/DSL/coeff.hpp"
#include "NeoFOAM/dsl/coeff.hpp"

using Field = NeoFOAM::Field<NeoFOAM::scalar>;
using Coeff = NeoFOAM::DSL::Coeff;
using Coeff = NeoFOAM::dsl::Coeff;

namespace detail = NeoFOAM::DSL::detail;
namespace detail = NeoFOAM::dsl::detail;


TEST_CASE("Coeff")
Expand Down
14 changes: 8 additions & 6 deletions test/dsl/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,19 @@
#include <catch2/benchmark/catch_benchmark.hpp>

#include "NeoFOAM/fields/field.hpp"
#include "NeoFOAM/DSL/coeff.hpp"
#include "NeoFOAM/DSL/operator.hpp"
#include "NeoFOAM/finiteVolume/cellCentred/fields/volumeField.hpp"
#include "NeoFOAM/dsl/coeff.hpp"
#include "NeoFOAM/dsl/operator.hpp"

namespace fvcc = NeoFOAM::finiteVolume::cellCentred;

using Field = NeoFOAM::Field<NeoFOAM::scalar>;
using Coeff = NeoFOAM::DSL::Coeff;
using Operator = NeoFOAM::DSL::Operator;
using OperatorMixin = NeoFOAM::DSL::OperatorMixin;
using Coeff = NeoFOAM::dsl::Coeff;
using Operator = NeoFOAM::dsl::Operator;
using OperatorMixin = NeoFOAM::dsl::OperatorMixin;
using Executor = NeoFOAM::Executor;
using VolumeField = fvcc::VolumeField<NeoFOAM::scalar>;
using BoundaryFields = NeoFOAM::BoundaryFields<NeoFOAM::scalar>;
namespace fvcc = NeoFOAM::finiteVolume::cellCentred;

/* A dummy implementation of a Operator
* following the Operator interface */
Expand Down
4 changes: 2 additions & 2 deletions test/dsl/equation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
#define CATCH_CONFIG_RUNNER // Define this before including catch.hpp to create
// a custom main
#include "common.hpp"
#include "NeoFOAM/DSL/equation.hpp"
#include "NeoFOAM/dsl/equation.hpp"

using Equation = NeoFOAM::DSL::Equation;
using Equation = NeoFOAM::dsl::Equation;

TEST_CASE("Equation")
{
Expand Down
File renamed without changes.
1 change: 0 additions & 1 deletion test/finiteVolume/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@
add_subdirectory(cellCentred/fields)
add_subdirectory(cellCentred/boundary)
add_subdirectory(cellCentred/interpolation)
add_subdirectory(cellCentred/timeIntegration)

0 comments on commit 4791d62

Please sign in to comment.