Skip to content

Commit

Permalink
wip add vector field interpolation
Browse files Browse the repository at this point in the history
  • Loading branch information
greole committed Feb 8, 2025
1 parent 3984dd2 commit 3d577ff
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 6 deletions.
10 changes: 10 additions & 0 deletions include/NeoFOAM/finiteVolume/cellCentred/interpolation/linear.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@ class Linear : public SurfaceInterpolationFactory::Register<Linear>
SurfaceField<scalar>& surfaceField
) const override;

void interpolate(const VolumeField<Vector>& volField, SurfaceField<Vector>& surfaceField)
const override;

void interpolate(
const SurfaceField<scalar>& faceFlux,
const VolumeField<Vector>& volField,
SurfaceField<Vector>& surfaceField
) const override;


std::unique_ptr<SurfaceInterpolationFactory> clone() const override;

private:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@
namespace NeoFOAM::finiteVolume::cellCentred
{

/* @class SurfaceInterpolationFactor
**
*/
class SurfaceInterpolationFactory :
public NeoFOAM::RuntimeSelectionFactory<
public RuntimeSelectionFactory<
SurfaceInterpolationFactory,
Parameters<const Executor&, const UnstructuredMesh&, Input>>
{
Expand Down Expand Up @@ -48,12 +51,21 @@ class SurfaceInterpolationFactory :
virtual ~SurfaceInterpolationFactory() {} // Virtual destructor

virtual void
interpolate(const VolumeField<scalar>& volField, ScalarSurfaceField& surfaceField) const = 0;
interpolate(const VolumeField<scalar>& volField, SurfaceField<scalar>& surfaceField) const = 0;

virtual void interpolate(
const ScalarSurfaceField& faceFlux,
const VolumeField<scalar>& volField,
ScalarSurfaceField& surfaceField
SurfaceField<scalar>& surfaceField
) const = 0;

virtual void
interpolate(const VolumeField<Vector>& volField, SurfaceField<Vector>& surfaceField) const = 0;

virtual void interpolate(
const ScalarSurfaceField& faceFlux,
const VolumeField<Vector>& volField,
SurfaceField<Vector>& surfaceField
) const = 0;

// Pure virtual function for cloning
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ class Upwind : public SurfaceInterpolationFactory::Register<Upwind>
SurfaceField<scalar>& surfaceField
) const override;

void interpolate(const VolumeField<Vector>& volField, SurfaceField<Vector>& surfaceField)
const override;

void interpolate(
const SurfaceField<scalar>& faceFlux,
const VolumeField<Vector>& volField,
SurfaceField<Vector>& surfaceField
) const override;

std::unique_ptr<SurfaceInterpolationFactory> clone() const override;

private:
Expand Down
20 changes: 19 additions & 1 deletion src/finiteVolume/cellCentred/interpolation/linear.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ Linear::Linear(const Executor& exec, const UnstructuredMesh& mesh)
void Linear::interpolate(const VolumeField<scalar>& volField, SurfaceField<scalar>& surfaceField)
const
{
computeLinearInterpolation(volField, geometryScheme_, surfaceField);
// FIXME:

Check failure on line 61 in src/finiteVolume/cellCentred/interpolation/linear.cpp

View workflow job for this annotation

GitHub Actions / FIXME check

// FIXME:
// computeLinearInterpolation(volField, geometryScheme_, surfaceField);
}

void Linear::interpolate(
Expand All @@ -70,6 +71,23 @@ void Linear::interpolate(
interpolate(volField, surfaceField);
}

void Linear::interpolate(const VolumeField<Vector>& volField, SurfaceField<Vector>& surfaceField)
const
{
// FIXME:

Check failure on line 77 in src/finiteVolume/cellCentred/interpolation/linear.cpp

View workflow job for this annotation

GitHub Actions / FIXME check

// FIXME:
// computeLinearInterpolation(volField, geometryScheme_, surfaceField);
}

void Linear::interpolate(
[[maybe_unused]] const SurfaceField<scalar>& faceFlux,
const VolumeField<Vector>& volField,
SurfaceField<Vector>& surfaceField
) const
{
interpolate(volField, surfaceField);
}


std::unique_ptr<SurfaceInterpolationFactory> Linear::clone() const
{
return std::make_unique<Linear>(*this);
Expand Down
21 changes: 20 additions & 1 deletion src/finiteVolume/cellCentred/interpolation/upwind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,26 @@ void Upwind::interpolate(
SurfaceField<scalar>& surfaceField
) const
{
computeUpwindInterpolation(faceFlux, volField, geometryScheme_, surfaceField);
// FIXME:

Check failure on line 76 in src/finiteVolume/cellCentred/interpolation/upwind.cpp

View workflow job for this annotation

GitHub Actions / FIXME check

// FIXME:
// computeUpwindInterpolation(faceFlux, volField, geometryScheme_, surfaceField);
}

void Upwind::interpolate(
[[maybe_unused]] const VolumeField<Vector>& volField,
[[maybe_unused]] SurfaceField<Vector>& surfaceField
) const
{
NF_ERROR_EXIT("limited scheme require a faceFlux");
}

void Upwind::interpolate(
const SurfaceField<scalar>& faceFlux,
const VolumeField<Vector>& volField,
SurfaceField<Vector>& surfaceField
) const
{
// FIXME:

Check failure on line 94 in src/finiteVolume/cellCentred/interpolation/upwind.cpp

View workflow job for this annotation

GitHub Actions / FIXME check

// FIXME:
// computeUpwindInterpolation(faceFlux, volField, geometryScheme_, surfaceField);
}

std::unique_ptr<SurfaceInterpolationFactory> Upwind::clone() const
Expand Down
4 changes: 3 additions & 1 deletion test/finiteVolume/cellCentred/interpolation/linear.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ TEST_CASE("linear")
);

std::string execName = std::visit([](auto e) { return e.name(); }, exec);
auto mesh = NeoFOAM::createSingleCellMesh(exec);
auto mesh = NeoFOAM::create1DUniformMesh(exec, 10);
NeoFOAM::Input input = NeoFOAM::TokenList({std::string("linear")});
auto linear = SurfaceInterpolation(exec, mesh, input);

auto in = VolumeField<NeoFOAM::scalar>(exec, "in", mesh, {});
auto out = SurfaceField<NeoFOAM::scalar>(exec, "out", mesh, {});

linear.interpolate(in, out);
}

0 comments on commit 3d577ff

Please sign in to comment.