Commit 19f04585 authored by Michael Turner's avatar Michael Turner

rework of source lines

parent cd528440
......@@ -104,6 +104,16 @@ NekDouble Octree::Query(Array<OneD, NekDouble> loc)
{
// starting at master octant 0 move through succsesive m_octants which
// contain the point loc until a leaf is found
//first search through sourcepoints
for(int i = 0; i < m_lsources.size(); i++)
{
if(m_lsources[i].withinRange(loc))
{
return m_lsources[i].delta;
}
}
OctantSharedPtr n = m_masteroct;
int quad;
......@@ -817,59 +827,6 @@ int Octree::CountElemt()
return int(total);
}
//struct to assist in the creation of linesources in the code
struct linesource
{
Array<OneD, NekDouble> x1, x2;
NekDouble R, delta;
linesource(Array<OneD, NekDouble> p1,
Array<OneD, NekDouble> p2,
NekDouble r,
NekDouble d)
: x1(p1), x2(p2), R(r), delta(d)
{
}
bool withinRange(Array<OneD, NekDouble> p)
{
Array<OneD, NekDouble> Le(3), Re(3), s(3);
for (int i = 0; i < 3; i++)
{
Le[i] = p[i] - x1[i];
Re[i] = p[i] - x2[i];
s[i] = x2[i] - x1[i];
}
Array<OneD, NekDouble> dev(3);
dev[0] = Le[1] * Re[2] - Re[1] * Le[2];
dev[1] = Le[0] * Re[2] - Re[0] * Le[2];
dev[2] = Le[0] * Re[1] - Re[0] * Le[1];
NekDouble dist =
sqrt(dev[0] * dev[0] + dev[1] * dev[1] + dev[2] * dev[2]) /
sqrt(s[0] * s[0] + s[1] * s[1] + s[2] * s[2]);
NekDouble t = -1.0 * ((x1[0] - p[0]) * s[0] + (x1[1] - p[1]) * s[1] +
(x1[1] - p[1]) * s[1]) /
Length() / Length();
if (dist < R && !(t > 1) && !(t < 0))
{
return true;
}
else
{
return false;
}
}
NekDouble Length()
{
return sqrt((x1[0] - x2[0]) * (x1[0] - x2[0]) +
(x1[1] - x2[1]) * (x1[1] - x2[1]) +
(x1[2] - x2[2]) * (x1[2] - x2[2]));
}
};
void Octree::CompileSourcePointList()
{
......@@ -1057,7 +1014,6 @@ void Octree::CompileSourcePointList()
cout << "\t\tModifying based on refinement lines" << endl;
}
// now deal with the user defined spacing
vector<linesource> lsources;
vector<string> lines;
boost::split(lines, m_refinement, boost::is_any_of(":"));
......@@ -1076,16 +1032,16 @@ void Octree::CompileSourcePointList()
x2[1] = data[4];
x2[2] = data[5];
lsources.push_back(linesource(x1, x2, data[6], data[7]));
m_lsources.push_back(linesource(x1, x2, data[6], data[7]));
}
// this takes any existing sourcepoints within the influence range
// and modifies them
for (int i = 0; i < m_SPList.size(); i++)
/*for (int i = 0; i < m_SPList.size(); i++)
{
for (int j = 0; j < lsources.size(); j++)
for (int j = 0; j < m_lsources.size(); j++)
{
if (lsources[j].withinRange(m_SPList[i]->GetLoc()))
if (m_lsources[j].withinRange(m_SPList[i]->GetLoc()))
{
if(m_SPList[i]->GetType() == ePBoundary)
{
......@@ -1096,10 +1052,10 @@ void Octree::CompileSourcePointList()
m_SPList[i] = bp->ChangeType();
}
m_SPList[i]->SetDelta(lsources[j].delta);
m_SPList[i]->SetDelta(m_lsources[j].delta);
}
}
}
}*/
///TODO add extra source points from the line souce to the octree
}
}
......
......@@ -47,6 +47,59 @@ namespace Nektar
namespace NekMeshUtils
{
//struct to assist in the creation of linesources in the code
struct linesource
{
Array<OneD, NekDouble> x1, x2;
NekDouble R, delta;
linesource(Array<OneD, NekDouble> p1,
Array<OneD, NekDouble> p2,
NekDouble r,
NekDouble d)
: x1(p1), x2(p2), R(r), delta(d)
{
}
bool withinRange(Array<OneD, NekDouble> p)
{
Array<OneD, NekDouble> Le(3), Re(3), s(3);
for (int i = 0; i < 3; i++)
{
Le[i] = p[i] - x1[i];
Re[i] = p[i] - x2[i];
s[i] = x2[i] - x1[i];
}
Array<OneD, NekDouble> dev(3);
dev[0] = Le[1] * Re[2] - Re[1] * Le[2];
dev[1] = Le[0] * Re[2] - Re[0] * Le[2];
dev[2] = Le[0] * Re[1] - Re[0] * Le[1];
NekDouble dist =
sqrt(dev[0] * dev[0] + dev[1] * dev[1] + dev[2] * dev[2]) /
sqrt(s[0] * s[0] + s[1] * s[1] + s[2] * s[2]);
NekDouble t = -1.0 * ((x1[0] - p[0]) * s[0] + (x1[1] - p[1]) * s[1] +
(x1[1] - p[1]) * s[1]) /
Length() / Length();
if (dist < R && !(t > 1) && !(t < 0))
{
return true;
}
else
{
return false;
}
}
NekDouble Length()
{
return sqrt((x1[0] - x2[0]) * (x1[0] - x2[0]) +
(x1[1] - x2[1]) * (x1[1] - x2[1]) +
(x1[2] - x2[2]) * (x1[2] - x2[2]));
}
};
/**
* @brief class for octree
*
......@@ -188,6 +241,7 @@ private:
MeshSharedPtr m_mesh;
std::string m_refinement;
std::vector<linesource> m_lsources;
};
typedef boost::shared_ptr<Octree> OctreeSharedPtr;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment