Added: Class for immersed boundary through a scalar function

This commit is contained in:
Knut Morten Okstad 2019-09-12 13:56:13 +02:00
parent 00934a726f
commit c6add776c7
2 changed files with 50 additions and 5 deletions

View File

@ -13,6 +13,7 @@
#include "IBGeometries.h"
#include "ElementBlock.h"
#include "Function.h"
Oval2D::Oval2D (double r, double x0, double y0, double x1, double y1)
@ -143,8 +144,7 @@ ElementBlock* PerforatedPlate2D::tesselate () const
PerforatedPlate2D::~PerforatedPlate2D ()
{
for (size_t i = 0; i < holes.size(); i++)
delete holes[i];
for (Hole2D* h : holes) delete h;
}
@ -160,3 +160,24 @@ void PerforatedPlate2D::addHole (double r,
{
holes.push_back(new Oval2D(r,x0,y0,x1,y1));
}
GeoFunc2D::GeoFunc2D (RealFunc* f, double p, double eps)
{
myAlpha = f;
myExponent = p;
threshold = eps;
}
GeoFunc2D::~GeoFunc2D ()
{
delete myAlpha;
}
double GeoFunc2D::Alpha (double X, double Y, double Z) const
{
double value = myAlpha ? pow((*myAlpha)(Vec3(X,Y,Z)),myExponent) : 0.0;
return value < threshold ? 0.0 : 1.0;
}

View File

@ -16,6 +16,8 @@
#include "ImmersedBoundaries.h"
class RealFunc;
/*!
\brief Class representing the perforated plate benchmark.
@ -70,7 +72,7 @@ public:
virtual ~Oval2D() {}
//! \brief Performs the inside-outside test for the perforated plate object.
virtual double Alpha(double X, double Y, double = 0.0) const;
virtual double Alpha(double X, double Y, double) const;
//! \brief Creates a finite element model of the geometry for visualization.
virtual ElementBlock* tesselate() const;
@ -93,7 +95,7 @@ public:
//! \brief Default constructor.
PerforatedPlate2D() {}
//! \brief Constructor creating a single hole.
explicit PerforatedPlate2D(Hole2D* hole) { holes.resize(1,hole); }
explicit PerforatedPlate2D(Hole2D* hole) : holes({hole}) { }
//! \brief The destructor deletes the holes.
virtual ~PerforatedPlate2D();
@ -103,7 +105,7 @@ public:
void addHole(double r, double x0, double y0, double x1, double y1);
//! \brief Performs the inside-outside test for the perforated plate object.
virtual double Alpha(double X, double Y, double = 0.0) const;
virtual double Alpha(double X, double Y, double) const;
//! \brief Creates a finite element model of the geometry for visualization.
virtual ElementBlock* tesselate() const;
@ -112,4 +114,26 @@ private:
std::vector<Hole2D*> holes; //!< The holes that perforate the plate
};
/*!
\brief Class describing the immersed boundary as a scalar function.
*/
class GeoFunc2D : public Immersed::Geometry
{
public:
//! \brief Default constructor.
explicit GeoFunc2D(RealFunc* f = nullptr, double p = 1.0, double eps = 0.5);
//! \brief The destructor deletes the function.
virtual ~GeoFunc2D();
//! \brief Performs the inside-outside test for the geometric object.
virtual double Alpha(double X, double Y, double Z) const;
private:
RealFunc* myAlpha; //!< Function describing the inside-outside state
double myExponent; //!< The exponent to apply on the \a myAlpha function
double threshold; //!< Inside/outside threshold
};
#endif