Skip to content

Commit

Permalink
Use explicit namespacing in lsInternal to avoid duplicate symbols
Browse files Browse the repository at this point in the history
  • Loading branch information
tobre1 committed Jun 17, 2024
1 parent eb94bad commit dd99dc3
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 41 deletions.
15 changes: 8 additions & 7 deletions include/viennals/lsEnquistOsher.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,28 @@

namespace lsInternal {

using namespace viennals;
using namespace viennacore;

/// Engquist osher integration scheme based on the
/// upwind integration scheme. Offers high performance
/// but lower accuracy for complex velocity fields.
template <class T, int D, int order> class EnquistOsher {
SmartPointer<Domain<T, D>> levelSet;
SmartPointer<VelocityField<T>> velocities;
SmartPointer<viennals::Domain<T, D>> levelSet;
SmartPointer<viennals::VelocityField<T>> velocities;
hrleSparseStarIterator<hrleDomain<T, D>, order> neighborIterator;
bool calculateNormalVectors = true;

static T pow2(const T &value) { return value * value; }

public:
static void prepareLS(SmartPointer<Domain<T, D>> passedlsDomain) {
static void prepareLS(SmartPointer<viennals::Domain<T, D>> passedlsDomain) {
assert(order == 1 || order == 2);
Expand<T, D>(passedlsDomain, 2 * order + 1).apply();
viennals::Expand<T, D>(passedlsDomain, 2 * order + 1).apply();
}

EnquistOsher(SmartPointer<Domain<T, D>> passedlsDomain,
SmartPointer<VelocityField<T>> vel, bool calcNormal = true)
EnquistOsher(SmartPointer<viennals::Domain<T, D>> passedlsDomain,
SmartPointer<viennals::VelocityField<T>> vel,
bool calcNormal = true)
: levelSet(passedlsDomain), velocities(vel),
neighborIterator(hrleSparseStarIterator<hrleDomain<T, D>, order>(
levelSet->getDomain())),
Expand Down
16 changes: 8 additions & 8 deletions include/viennals/lsLaxFriedrichs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,30 @@

namespace lsInternal {

using namespace viennals;
using namespace viennacore;

/// Lax Friedrichs integration scheme with constant alpha
/// value for dissipation. This alpha value should be fitted
/// based on the results of the advection and passed to the
/// advection Kernel.
template <class T, int D, int order> class LaxFriedrichs {
SmartPointer<Domain<T, D>> levelSet;
SmartPointer<VelocityField<T>> velocities;
SmartPointer<viennals::Domain<T, D>> levelSet;
SmartPointer<viennals::VelocityField<T>> velocities;
hrleSparseStarIterator<hrleDomain<T, D>, order> neighborIterator;
bool calculateNormalVectors = true;
const double alpha = 1.0;

static T pow2(const T &value) { return value * value; }

public:
static void prepareLS(SmartPointer<Domain<T, D>> passedlsDomain) {
static void prepareLS(SmartPointer<viennals::Domain<T, D>> passedlsDomain) {
assert(order == 1 || order == 2);
Expand<T, D>(passedlsDomain, 2 * order + 1).apply();
viennals::Expand<T, D>(passedlsDomain, 2 * order + 1).apply();
}

LaxFriedrichs(SmartPointer<Domain<T, D>> passedlsDomain,
SmartPointer<VelocityField<T>> vel, bool calcNormal = true,
double a = 1.0)
LaxFriedrichs(SmartPointer<viennals::Domain<T, D>> passedlsDomain,
SmartPointer<viennals::VelocityField<T>> vel,
bool calcNormal = true, double a = 1.0)
: levelSet(passedlsDomain), velocities(vel),
neighborIterator(hrleSparseStarIterator<hrleDomain<T, D>, order>(
levelSet->getDomain())),
Expand Down
16 changes: 9 additions & 7 deletions include/viennals/lsLocalLaxFriedrichs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,22 @@

#include <lsDomain.hpp>
#include <lsExpand.hpp>
#include <lsVelocityField.hpp>

#include <vcVectorUtil.hpp>

namespace lsInternal {

using namespace viennals;
using namespace viennacore;

/// Lax Friedrichs integration scheme, which uses a first neighbour
/// stencil to calculate the alpha values for all neighbours.
/// The largest alpha value is then chosen for dissipation.
/// Slower than lsLocalLocalLaxFriedrichs or lsEngquistOsher
/// but more reliable for complex velocity fields.
template <class T, int D, int order> class LocalLaxFriedrichs {
SmartPointer<Domain<T, D>> levelSet;
SmartPointer<VelocityField<T>> velocities;
SmartPointer<viennals::Domain<T, D>> levelSet;
SmartPointer<viennals::VelocityField<T>> velocities;
hrleSparseBoxIterator<hrleDomain<T, D>> neighborIterator;
const double alphaFactor;

Expand All @@ -43,16 +44,17 @@ template <class T, int D, int order> class LocalLaxFriedrichs {
}

public:
static void prepareLS(SmartPointer<Domain<T, D>> passedlsDomain) {
static void prepareLS(SmartPointer<viennals::Domain<T, D>> passedlsDomain) {
assert(order == 1 || order == 2);
// at least order+1 layers since we need neighbor neighbors for
// dissipation alpha calculation
Expand<T, D>(passedlsDomain, 2 * (order + 2) + 1).apply();
viennals::Expand<T, D>(passedlsDomain, 2 * (order + 2) + 1).apply();
}

// neighboriterator always needs order 2 for alpha calculation
LocalLaxFriedrichs(SmartPointer<Domain<T, D>> passedlsDomain,
SmartPointer<VelocityField<T>> vel, double a = 1.0)
LocalLaxFriedrichs(SmartPointer<viennals::Domain<T, D>> passedlsDomain,
SmartPointer<viennals::VelocityField<T>> vel,
double a = 1.0)
: levelSet(passedlsDomain), velocities(vel),
neighborIterator(levelSet->getDomain(), 2), alphaFactor(a) {}

Expand Down
16 changes: 9 additions & 7 deletions include/viennals/lsLocalLaxFriedrichsAnalytical.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,22 @@

#include <lsDomain.hpp>
#include <lsExpand.hpp>
#include <lsVelocityField.hpp>

#include <vcVectorUtil.hpp>

namespace lsInternal {

using namespace viennals;
using namespace viennacore;

/// Lax Friedrichs integration scheme, which uses alpha values
/// provided by the user in getDissipationAlphas in lsVelocityField.
/// If it is possible to derive analytical solutions for the velocityField
/// and the alpha values, this integration scheme should be used and never
/// otherwise.
template <class T, int D, int order> class LocalLaxFriedrichsAnalytical {
SmartPointer<Domain<T, D>> levelSet;
SmartPointer<VelocityField<T>> velocities;
SmartPointer<viennals::Domain<T, D>> levelSet;
SmartPointer<viennals::VelocityField<T>> velocities;
hrleSparseBoxIterator<hrleDomain<T, D>> neighborIterator;

static T pow2(const T &value) { return value * value; }
Expand All @@ -42,16 +43,17 @@ template <class T, int D, int order> class LocalLaxFriedrichsAnalytical {
}

public:
static void prepareLS(SmartPointer<Domain<T, D>> passedlsDomain) {
static void prepareLS(SmartPointer<viennals::Domain<T, D>> passedlsDomain) {
assert(order == 1 || order == 2);
// at least order+1 layers since we need neighbor neighbors for
// dissipation alpha calculation
Expand<T, D>(passedlsDomain, 2 * (order + 2) + 1).apply();
viennals::Expand<T, D>(passedlsDomain, 2 * (order + 2) + 1).apply();
}

// neighboriterator always needs order 2 for alpha calculation
LocalLaxFriedrichsAnalytical(SmartPointer<Domain<T, D>> passedlsDomain,
SmartPointer<VelocityField<T>> vel)
LocalLaxFriedrichsAnalytical(
SmartPointer<viennals::Domain<T, D>> passedlsDomain,
SmartPointer<viennals::VelocityField<T>> vel)
: levelSet(passedlsDomain), velocities(vel),
neighborIterator(levelSet->getDomain(), 2) {}

Expand Down
16 changes: 9 additions & 7 deletions include/viennals/lsLocalLocalLaxFriedrichs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,34 @@

#include <lsDomain.hpp>
#include <lsExpand.hpp>
#include <lsVelocityField.hpp>

#include <vcVectorUtil.hpp>

namespace lsInternal {

using namespace viennals;
using namespace viennacore;

/// Lax Friedrichs integration scheme, which considers only the current
/// point for alpha calculation. Faster than lsLocalLaxFriedrichs but
/// not as accurate.
template <class T, int D, int order> class LocalLocalLaxFriedrichs {
SmartPointer<Domain<T, D>> levelSet;
SmartPointer<VelocityField<T>> velocities;
SmartPointer<viennals::Domain<T, D>> levelSet;
SmartPointer<viennals::VelocityField<T>> velocities;
hrleSparseStarIterator<hrleDomain<T, D>, order> neighborIterator;
const double alphaFactor;

static T pow2(const T &value) { return value * value; }

public:
static void prepareLS(SmartPointer<Domain<T, D>> passedlsDomain) {
static void prepareLS(SmartPointer<viennals::Domain<T, D>> passedlsDomain) {
assert(order == 1 || order == 2);
Expand<T, D>(passedlsDomain, 2 * order + 1).apply();
viennals::Expand<T, D>(passedlsDomain, 2 * order + 1).apply();
}

LocalLocalLaxFriedrichs(SmartPointer<Domain<T, D>> passedlsDomain,
SmartPointer<VelocityField<T>> vel, double a = 1.0)
LocalLocalLaxFriedrichs(SmartPointer<viennals::Domain<T, D>> passedlsDomain,
SmartPointer<viennals::VelocityField<T>> vel,
double a = 1.0)
: levelSet(passedlsDomain), velocities(vel),
neighborIterator(hrleSparseStarIterator<hrleDomain<T, D>, order>(
levelSet->getDomain())),
Expand Down
11 changes: 6 additions & 5 deletions include/viennals/lsStencilLocalLaxFriedrichsScalar.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
#include <lsDomain.hpp>
#include <lsExpand.hpp>
#include <lsFiniteDifferences.hpp>
#include <lsVelocityField.hpp>

namespace lsInternal {

using namespace viennals;
using namespace viennacore;

/// Stencil Local Lax Friedrichs Integration Scheme.
/// It uses a stencil of order around active points, in order to
Expand All @@ -18,11 +19,11 @@ using namespace viennals;
/// see Toifl et al., 2019. ISBN: 978-1-7281-0938-1;
/// DOI: 10.1109/SISPAD.2019.8870443
template <class T, int D, int order> class StencilLocalLaxFriedrichsScalar {
using LevelSetType = SmartPointer<Domain<T, D>>;
using LevelSetType = SmartPointer<viennals::Domain<T, D>>;
using LevelSetsType = std::vector<LevelSetType>;

LevelSetType levelSet;
SmartPointer<VelocityField<T>> velocities;
SmartPointer<viennals::VelocityField<T>> velocities;
const DifferentiationSchemeEnum finiteDifferenceScheme =
DifferentiationSchemeEnum::FIRST_ORDER;
hrleSparseBoxIterator<hrleDomain<T, D>> neighborIterator;
Expand Down Expand Up @@ -132,11 +133,11 @@ template <class T, int D, int order> class StencilLocalLaxFriedrichsScalar {
static void prepareLS(LevelSetType passedlsDomain) {
// Expansion of sparse field must depend on spatial derivative order
// AND slf stencil order! --> currently assume scheme = 3rd order always
Expand<T, D>(passedlsDomain, 2 * (order + 1) + 4).apply();
viennals::Expand<T, D>(passedlsDomain, 2 * (order + 1) + 4).apply();
}

StencilLocalLaxFriedrichsScalar(
LevelSetType passedlsDomain, SmartPointer<VelocityField<T>> vel,
LevelSetType passedlsDomain, SmartPointer<viennals::VelocityField<T>> vel,
double a = 1.0,
DifferentiationSchemeEnum scheme = DifferentiationSchemeEnum::FIRST_ORDER)
: levelSet(passedlsDomain), velocities(vel),
Expand Down

0 comments on commit dd99dc3

Please sign in to comment.