15 #include "../config/config.hpp" 16 #include "../general/table.hpp" 17 #include "../linalg/vector.hpp" 21 #include "../general/communication.hpp" 61 {
return (xi*
knot(ni+1) + (1. - xi)*
knot(ni)); }
120 inline double &
slice(
int i,
int j);
121 inline const double &
slice(
int i,
int j)
const;
139 void Print(std::ostream &
out)
const;
159 inline const double &
operator()(
int i,
int j)
const;
161 inline double &
operator()(
int i,
int j,
int l);
162 inline const double &
operator()(
int i,
int j,
int l)
const;
164 inline double &
operator()(
int i,
int j,
int k,
int l);
165 inline const double &
operator()(
int i,
int j,
int k,
int l)
const;
177 void Rotate(
double angle,
double normal[]= NULL);
179 void Rotate3D(
double normal[],
double angle);
191 class ParNURBSExtension;
260 inline int KnotInd(
int edge)
const;
400 void Print(std::ostream &
out)
const;
512 Table *GetGlobalElementDofTable();
513 Table *Get1DGlobalElementDofTable();
514 Table *Get2DGlobalElementDofTable();
515 Table *Get3DGlobalElementDofTable();
517 void SetActive(
const int *partitioning,
const Array<bool> &active_bel);
518 void BuildGroups(
const int *partitioning,
const Table &elem_dof);
546 int I, J, K, pOffset, opatch;
549 inline static int F(
const int n,
const int N)
550 {
return (n < 0) ? 0 : ((n >= N) ? 2 : 1); }
552 inline static int Or1D(
const int n,
const int N,
const int Or)
553 {
return (Or > 0) ? n : (N - 1 - n); }
555 inline static int Or2D(
const int n1,
const int n2,
556 const int N1,
const int N2,
const int Or);
559 void GetPatchKnotVectors (
int p,
const KnotVector *kv[]);
560 void GetBdrPatchKnotVectors(
int p,
const KnotVector *kv[],
int *okv);
565 int nx() {
return I + 1; }
566 int ny() {
return J + 1; }
567 int nz() {
return K + 1; }
576 inline int operator[](
const int i)
const {
return (*
this)(i); }
578 inline int operator()(
const int i,
const int j)
const;
580 inline int operator()(
const int i,
const int j,
const int k)
const;
589 if (
data == 0 || i < 0 || i >=
nd || j < 0 || j >
ls)
600 if (
data == 0 || i < 0 || i >=
nd || j < 0 || j >
ls)
612 if (
data == 0 || i < 0 || i >=
ni ||
nj > 0 ||
nk > 0 ||
625 if (
data == 0 || i < 0 || i >=
ni ||
nj > 0 ||
nk > 0 ||
628 mfem_error(
"NURBSPatch::operator() const 1D");
638 if (
data == 0 || i < 0 || i >=
ni || j < 0 || j >=
nj ||
nk > 0 ||
651 if (
data == 0 || i < 0 || i >=
ni || j < 0 || j >=
nj ||
nk > 0 ||
654 mfem_error(
"NURBSPatch::operator() const 2D");
664 if (
data == 0 || i < 0 || i >=
ni || j < 0 || j >=
nj || k < 0 ||
665 k >=
nk || l < 0 || l >=
Dim)
677 if (
data == 0 || i < 0 || i >=
ni || j < 0 || j >=
nj || k < 0 ||
678 k >=
nk || l < 0 || l >=
Dim)
680 mfem_error(
"NURBSPatch::operator() const 3D");
691 return (kv >= 0) ? kv : (-1-kv);
722 inline int NURBSPatchMap::Or2D(
const int n1,
const int n2,
723 const int N1,
const int N2,
const int Or)
728 case 0:
return n1 + n2*N1;
729 case 1:
return n2 + n1*N2;
730 case 2:
return n2 + (N1 - 1 - n1)*N2;
731 case 3:
return (N1 - 1 - n1) + n2*N1;
732 case 4:
return (N1 - 1 - n1) + (N2 - 1 - n2)*N1;
733 case 5:
return (N2 - 1 - n2) + (N1 - 1 - n1)*N2;
734 case 6:
return (N2 - 1 - n2) + n1*N2;
735 case 7:
return n1 + (N2 - 1 - n2)*N1;
745 const int i1 = i - 1;
748 case 0:
return verts[0];
749 case 1:
return pOffset + Or1D(i1, I, opatch);
750 case 2:
return verts[1];
753 mfem_error(
"NURBSPatchMap::operator() const 1D");
760 const int i1 = i - 1, j1 = j - 1;
761 switch (3*F(j1, J) + F(i1, I))
763 case 0:
return verts[0];
764 case 1:
return edges[0] + Or1D(i1, I, oedge[0]);
765 case 2:
return verts[1];
766 case 3:
return edges[3] + Or1D(j1, J, -oedge[3]);
767 case 4:
return pOffset + Or2D(i1, j1, I, J, opatch);
768 case 5:
return edges[1] + Or1D(j1, J, oedge[1]);
769 case 6:
return verts[3];
770 case 7:
return edges[2] + Or1D(i1, I, -oedge[2]);
771 case 8:
return verts[2];
774 mfem_error(
"NURBSPatchMap::operator() const 2D");
783 const int i1 = i - 1, j1 = j - 1, k1 = k - 1;
784 switch (3*(3*F(k1, K) + F(j1, J)) + F(i1, I))
786 case 0:
return verts[0];
787 case 1:
return edges[0] + Or1D(i1, I, oedge[0]);
788 case 2:
return verts[1];
789 case 3:
return edges[3] + Or1D(j1, J, oedge[3]);
790 case 4:
return faces[0] + Or2D(i1, J - 1 - j1, I, J, oface[0]);
791 case 5:
return edges[1] + Or1D(j1, J, oedge[1]);
792 case 6:
return verts[3];
793 case 7:
return edges[2] + Or1D(i1, I, oedge[2]);
794 case 8:
return verts[2];
795 case 9:
return edges[8] + Or1D(k1, K, oedge[8]);
796 case 10:
return faces[1] + Or2D(i1, k1, I, K, oface[1]);
797 case 11:
return edges[9] + Or1D(k1, K, oedge[9]);
798 case 12:
return faces[4] + Or2D(J - 1 - j1, k1, J, K, oface[4]);
799 case 13:
return pOffset + I*(J*k1 + j1) + i1;
800 case 14:
return faces[2] + Or2D(j1, k1, J, K, oface[2]);
801 case 15:
return edges[11] + Or1D(k1, K, oedge[11]);
802 case 16:
return faces[3] + Or2D(I - 1 - i1, k1, I, K, oface[3]);
803 case 17:
return edges[10] + Or1D(k1, K, oedge[10]);
804 case 18:
return verts[4];
805 case 19:
return edges[4] + Or1D(i1, I, oedge[4]);
806 case 20:
return verts[5];
807 case 21:
return edges[7] + Or1D(j1, J, oedge[7]);
808 case 22:
return faces[5] + Or2D(i1, j1, I, J, oface[5]);
809 case 23:
return edges[5] + Or1D(j1, J, oedge[5]);
810 case 24:
return verts[7];
811 case 25:
return edges[6] + Or1D(i1, I, oedge[6]);
812 case 26:
return verts[6];
815 mfem_error(
"NURBSPatchMap::operator() const 3D");
Array< KnotVector * > knotVectors
Abstract class for all finite elements.
int GetElementPatch(int elem) const
Returns the index of the patch containing element elem.
Array< int > f_meshOffsets
NURBSPatch(NURBSPatch *parent, int dir, int Order, int NCP)
Array2D< int > bel_to_IJK
void SetPatchAttribute(int i, int attr)
void SetCoordsFromPatches(Vector &Nodes)
void Rotate2D(double angle)
Array< KnotVector * > knotVectorsCompr
void ConnectBoundaries2D(int bnd0, int bnd1)
KnotVector * KnotVec(int edge)
void swap(NURBSPatch *np)
Class for grid function - Vector with associated FE space.
void DegreeElevate(int dir, int t)
void Generate2DElementDofTable()
void MergeGridFunctions(GridFunction *gf_array[], int num_pieces, GridFunction &merged)
void PrintSolution(const GridFunction &sol, std::ostream &out) const
static void Get2DRotationMatrix(double angle, DenseMatrix &T)
virtual ~ParNURBSExtension()
void LoadFE(int i, const FiniteElement *FE) const
void Generate3DElementDofTable()
int Dimension() const
Dimension of the reference space used within the elements.
NURBSExtension & operator=(const NURBSExtension &)=delete
Copy assignment not supported.
void KnotInsert(int dir, const KnotVector &knot)
void MergeWeights(Mesh *mesh_array[], int num_pieces)
void Print(std::ostream &out) const
NURBSPatchMap(const NURBSExtension *ext)
void CalcDShape(Vector &grad, int i, double xi) const
const Array< int > & GetSlave() const
int DofMap(int dof) const
void PrintCharacteristics(std::ostream &out) const
void Get2DBdrElementTopo(Array< Element *> &boundary) const
double & slice(int i, int j)
void Rotate3D(double normal[], double angle)
Array< int > e_meshOffsets
int Size() const
Returns the size of the vector.
void GetElements()
Count the number of elements.
void SetOrdersFromKnotVectors()
Data type dense matrix using column-major storage.
void GetPatchDofs(const int patch, Array< int > &dofs)
void Generate1DBdrElementDofTable()
Array< int > & GetSlave()
void Generate3DBdrElementDofTable()
Array< int > e_spaceOffsets
void GetBdrElementTopo(Array< Element *> &boundary) const
const Vector & GetWeights() const
void GenerateBdrElementDofTable()
void CalcD2Shape(Vector &grad2, int i, double xi) const
std::vector< Array< int > > patch_to_el
void GetElementIJK(int elem, Array< int > &ijk)
void LoadSolution(std::istream &input, GridFunction &sol) const
void GetElementLocalToGlobal(Array< int > &lelem_elem)
void Get2DElementTopo(Array< Element *> &elements) const
void KnotInsert(Array< KnotVector *> &kv)
void Set1DSolutionVector(Vector &Nodes, int vdim)
void SetPatchToBdrElements()
void ConnectBoundaries1D(int bnd0, int bnd1)
Array< int > edge_to_knot
void GenerateActiveVertices()
void Print(std::ostream &out) const
void GetVertexLocalToGlobal(Array< int > &lvert_vert)
void Set2DSolutionVector(Vector &Nodes, int vdim)
int GetNBE() const
Returns number of boundary elements.
friend NURBSPatch * Revolve3D(NURBSPatch &patch, double n[], double ang, int times)
Array< int > & GetMaster()
void SwapDirections(int dir1, int dir2)
KnotVector()
Create KnotVector.
const Array< int > & GetMaster() const
static const int MaxOrder
Array< int > v_spaceOffsets
void GetElementTopo(Array< Element *> &elements) const
void FindMaxima(Array< int > &ks, Vector &xi, Vector &u)
int GetAttribute(int i) const
Return the attribute of element i.
void Generate2DBdrElementDofTable()
int KnotInd(int edge) const
void Generate1DElementDofTable()
void GetBdrPatchKnotVectors(int p, Array< KnotVector *> &kv)
void ConnectBoundaries3D(int bnd0, int bnd1)
ParNURBSExtension(const ParNURBSExtension &orig)
void Set3DSolutionVector(Vector &Nodes, int vdim)
void GenerateActiveBdrElems()
int GetOrder() const
If all orders are identical, return that number. Otherwise, return NURBSFECollection::VariableOrder.
void Get3DPatchNets(const Vector &Nodes, int vdim)
void mfem_error(const char *msg)
Function called when an error is encountered. Used by the macros MFEM_ABORT, MFEM_ASSERT, MFEM_VERIFY.
std::vector< Array< int > > patch_to_bel
const Array< int > & GetOrders() const
Read-only access to the orders of all knot vectors.
void Get2DPatchNets(const Vector &Nodes, int vdim)
int GetPatchAttribute(int i) const
virtual ~NURBSExtension()
Destroy a NURBSExtension.
void UniformRefinement(Vector &newknots) const
friend NURBSPatch * Interpolate(NURBSPatch &p1, NURBSPatch &p2)
void CalcDnShape(Vector &gradn, int n, int i, double xi) const
static void Get3DRotationMatrix(double n[], double angle, double r, DenseMatrix &T)
void SetKnotsFromPatches()
void FindInterpolant(Array< Vector *> &x)
Array< int > f_spaceOffsets
Array< bool > activeBdrElem
int operator()(const int i) const
KnotVector(const KnotVector &kv)
const Array< int > & GetPatchBdrElements(int patch)
void Get3DElementTopo(Array< Element *> &elements) const
void Get3DBdrElementTopo(Array< Element *> &boundary) const
int findKnotSpan(double u) const
int GetPatchBdrAttribute(int i) const
void SetPatchToElements()
KnotVector * GetKV(int i)
int GetBdrAttribute(int i) const
Return the attribute of boundary element i.
void Difference(const KnotVector &kv, Vector &diff) const
double p(const Vector &x, double t)
bool isElement(int i) const
void LoadBE(int i, const FiniteElement *BE) const
Array< int > v_meshOffsets
OutStream out(std::cout)
Global stream used by the library for standard output. Initially it uses the same std::streambuf as s...
void SetBdrPatchVertexMap(int p, const KnotVector *kv[], int *okv)
Array< int > p_meshOffsets
void GetPatchKnotVectors(int p, Array< KnotVector *> &kv)
KnotVector & operator=(const KnotVector &kv)
void SetPatchVertexMap(int p, const KnotVector *kv[])
void SetBdrAttribute(int i, int attr)
Set the attribute of boundary element i.
const Array< int > & GetPatchElements(int patch)
Table * GetElementDofTable()
Table * GetBdrElementDofTable()
void SetOrderFromOrders()
void Get1DBdrElementTopo(Array< Element *> &boundary) const
const double & operator[](int i) const
void CreateComprehensiveKV()
void Rotate(double angle, double normal[]=NULL)
Rotate the NURBSPatch.
int GetNE() const
Returns number of elements.
void CheckKVDirection(int p, Array< int > &kvdir)
void SetPatchBdrAttribute(int i, int attr)
void GetPatchNets(const Vector &Nodes, int vdim)
const KnotVector * GetKnotVector(int i) const
int MakeUniformDegree(int degree=-1)
Array< int > p_spaceOffsets
void SetSolutionVector(Vector &Nodes, int vdim)
void SetBdrPatchDofMap(int p, const KnotVector *kv[], int *okv)
double & operator()(int i, int j)
void CalcShape(Vector &shape, int i, double xi) const
void GenerateElementDofTable()
Array< NURBSPatch * > patches
~KnotVector()
Destroys KnotVector.
void Get1DElementTopo(Array< Element *> &elements) const
NURBSPatch & operator=(const NURBSPatch &)=delete
int operator[](const int i) const
int Size() const
Return the logical size of the array.
void SetAttribute(int i, int attr)
Set the attribute of element i.
void PrintFunctions(const char *filename, int samples=11) const
double u(const Vector &xvec)
void Get1DPatchNets(const Vector &Nodes, int vdim)
void DegreeElevate(int rel_degree, int degree=16)
void PrintFunctions(std::ostream &out, int samples=11) const
double getKnotLocation(double xi, int ni) const
double & operator[](int i)
void FlipDirection(int dir)
void Print(std::ostream &out) const
Array< int > bel_to_patch
void SetPatchDofMap(int p, const KnotVector *kv[])
void ConvertToPatches(const Vector &Nodes)
int SetLoopDirection(int dir)
KnotVector * DegreeElevate(int t) const