changed: introduce virtual getCorner method in ASM[2|3]D and getEdge in ASM3D

This commit is contained in:
Arne Morten Kvarving 2016-08-29 13:43:08 +02:00
parent 91a02aefbd
commit a3b635c371
9 changed files with 138 additions and 68 deletions

View File

@ -127,6 +127,9 @@ public:
//! \param[in] nSegSpan Number of visualization segments over each knot-span
virtual bool getGridParameters(std::vector<double>& prm,
int dir, int nSegSpan) const = 0;
//! \brief Returns the node index for a given corner.
virtual int getCorner(int I, int J, int basis = 1) const = 0;
};
#endif

View File

@ -159,6 +159,12 @@ public:
//! \param[in] nSegSpan Number of visualization segments over each knot-span
virtual bool getGridParameters(std::vector<double>& prm,
int dir, int nSegSpan) const = 0;
//! \brief Returns the node index for a given corner.
virtual int getCorner(int I, int J, int K, int basis = 1) const = 0;
//! \brief Returns the node indices for a given edge.
virtual std::vector<int> getEdge(int lEdge, bool open, int basis = 1) const = 0;
};
#endif

View File

@ -1016,19 +1016,8 @@ size_t ASMs2D::constrainEdgeLocal (int dir, bool open, int dof, int code,
void ASMs2D::constrainCorner (int I, int J, int dof, int code, char basis)
{
int n1, n2, node = 1;
for (char i = 1; i <= basis; i++)
if (!this->getSize(n1,n2,i))
return;
else if (i < basis)
node += n1*n2;
if (swapV) // Account for swapped parameter direction
J = -J;
if (I > 0) node += n1-1;
if (J > 0) node += n1*(n2-1);
int node = this->getCorner(I, J, basis);
if (node > -1)
this->prescribe(node,dof,code);
}
@ -2745,3 +2734,22 @@ bool ASMs2D::evaluate (const RealFunc* func, RealArray& vec,
return true;
}
int ASMs2D::getCorner(int I, int J, int basis) const
{
int n1, n2, node = 1;
for (char i = 1; i <= basis; i++)
if (!this->getSize(n1,n2,i))
return -1;
else if (i < basis)
node += n1*n2;
if (swapV) // Account for swapped parameter direction
J = -J;
if (I > 0) node += n1-1;
if (J > 0) node += n1*(n2-1);
return node;
}

View File

@ -185,6 +185,9 @@ public:
//! \param basis Which basis to grab nodes for
virtual void getBoundaryNodes(int lIndex, IntVec& glbNodes, int basis) const;
//! \brief Returns the node index for a given corner.
virtual int getCorner(int I, int J, int basis = 1) const;
//! \brief Assigns new global node numbers for all nodes of the patch.
//! \param nodes Object with global nodes numbers to assign to this patch
//! \param[in] basis Which basis to assign node numbers for in mixed methods

View File

@ -1110,12 +1110,12 @@ size_t ASMs3D::constrainFaceLocal (int dir, bool open, int dof, int code,
}
void ASMs3D::constrainEdge (int lEdge, bool open, int dof,
int code, char basis)
std::vector<int> ASMs3D::getEdge(int lEdge, bool open, int basis) const
{
std::vector<int> result;
int n1, n2, n3, n, inc = 1;
int node = this->findStartNode(n1,n2,n3,basis);
if (node < 1) return;
if (node < 1) return result;
if (swapW && lEdge <= 8) // Account for swapped parameter direction
lEdge += (lEdge-1)%4 < 2 ? 2 : -2;
@ -1161,6 +1161,17 @@ void ASMs3D::constrainEdge (int lEdge, bool open, int dof,
// Skip the first and last node if we are requesting an open boundary
for (int i = 1; i <= n; i++, node += inc)
if (!open || (i > 1 && i < n))
result.push_back(node);
return result;
}
void ASMs3D::constrainEdge (int lEdge, bool open, int dof,
int code, char basis)
{
std::vector<int> nodes = this->getEdge(lEdge, open, basis);
for (const int& node : nodes)
this->prescribe(node,dof,code);
}
@ -1242,16 +1253,9 @@ void ASMs3D::constrainLine (int fdir, int ldir, double xi, int dof,
void ASMs3D::constrainCorner (int I, int J, int K, int dof,
int code, char basis)
{
int n1, n2, n3;
int node = this->findStartNode(n1,n2,n3,basis);
if (node < 1) return;
if (swapW) // Account for swapped parameter direction
K = -K;
if (I > 0) node += n1-1;
if (J > 0) node += n1*(n2-1);
if (K > 0) node += n1*n2*(n3-1);
int node = this->getCorner(I, J, K, basis);
if (node < 1)
return;
this->prescribe(node,dof,code);
}
@ -3193,3 +3197,20 @@ bool ASMs3D::evaluate (const RealFunc* func, RealArray& vec,
return true;
}
int ASMs3D::getCorner(int I, int J, int K, int basis) const
{
int n1, n2, n3;
int node = this->findStartNode(n1,n2,n3,basis);
if (node < 1) return -1;
if (swapW) // Account for swapped parameter direction
K = -K;
if (I > 0) node += n1-1;
if (J > 0) node += n1*(n2-1);
if (K > 0) node += n1*n2*(n3-1);
return node;
}

View File

@ -201,6 +201,12 @@ public:
//! \param basis Which basis to grab nodes for (0 for all)
virtual void getBoundaryNodes(int lIndex, IntVec& glbNodes, int basis) const;
//! \brief Returns the node index for a given corner.
virtual int getCorner(int I, int J, int K, int basis = 1) const;
//! \brief Returns the node indices for a given edge.
virtual std::vector<int> getEdge(int lEdge, bool open, int basis = 1) const;
//! \brief Assigns new global node numbers for all nodes of the patch.
//! \param nodes Object with global nodes numbers to assign to this patch
//! \param[in] basis Which basis to assign node numbers for in mixed methods

View File

@ -235,7 +235,7 @@ public:
const std::map<int,int>* g2l = nullptr);
//! \brief Returns the node index for a given corner.
int getCorner(int I, int J, int basis = 1) const;
virtual int getCorner(int I, int J, int basis = 1) const;
//! \brief Returns the node indices for a given edge.
std::vector<int> getEdgeNodes(int edge, int basis = 1) const;

View File

@ -487,11 +487,9 @@ size_t ASMu3D::constrainFaceLocal(int dir, bool open, int dof, int code, bool pr
return 0;
}
void ASMu3D::constrainEdge (int lEdge, bool open, int dof, int code, char)
{
if(open)
std::cerr << "\nWARNING: ASMu3D::constrainEdge, open boundary conditions not supported yet. Treating it as closed" << std::endl;
std::vector<int> ASMu3D::getEdge(int lEdge, bool open, int) const
{
// lEdge = 1-4, running index is u (vmin,wmin), (vmax,wmin), (vmin,wmax), (vmax,wmax)
// lEdge = 5-8, running index is v (umin,wmin), (umax,wmin), (umin,wmax), (umax,wmax)
// lEdge = 9-12, running index is w
@ -525,10 +523,22 @@ void ASMu3D::constrainEdge (int lEdge, bool open, int dof, int code, char)
// get all the boundary functions from the LRspline object
std::vector<LR::Basisfunction*> thisEdge;
lrspline->getEdgeFunctions(thisEdge, (LR::parameterEdge) edge, 1);
std::vector<int> result;
for (LR::Basisfunction* b : thisEdge)
result.push_back(b->getId()+1);
return result;
}
void ASMu3D::constrainEdge (int lEdge, bool open, int dof, int code, char)
{
if(open)
std::cerr << "\nWARNING: ASMu3D::constrainEdge, open boundary conditions not supported yet. Treating it as closed" << std::endl;
// enforce the boundary conditions
for(LR::Basisfunction* b : thisEdge)
this->prescribe(b->getId()+1,dof,code);
std::vector<int> nodes = this->getEdge(lEdge, open, 1);
for (const int& node : nodes)
this->prescribe(node,dof,code);
}
@ -1972,3 +1982,10 @@ bool ASMu3D::getOrder (int& p1, int& p2, int& p3) const
return true;
}
int ASMu3D::getCorner(int I, int J, int K, int basis) const
{
std::cerr << "ASMu3D::getCorner not implemented properly yet" << std::endl;
exit(776654);
}

View File

@ -92,6 +92,12 @@ public:
//! \param glbNodes Array of global boundary node numbers
virtual void getBoundaryNodes(int lIndex, IntVec& glbNodes, int basis) const;
//! \brief Returns the node index for a given corner.
virtual int getCorner(int I, int J, int K, int basis = 1) const;
//! \brief Returns the node indices for a given edge.
virtual std::vector<int> getEdge(int lEdge, bool open, int basis = 1) const;
//! \brief Returns the polynomial order in each parameter direction.
//! \param[out] p1 Order in first (u) direction
//! \param[out] p2 Order in second (v) direction