43 static int order_ = 3;
46 static double R_ = 1.0;
47 static double r_ = 0.2;
48 static double theta0_ = 0.0;
50 void pts(
int iphi,
int t,
double x[]);
53 int main(
int argc,
char *argv[])
55 int ser_ref_levels = 0;
58 bool visualization =
true;
61 args.
AddOption(&nphi_,
"-nphi",
"--num-elements-phi",
62 "Number of elements in phi-direction.");
63 args.
AddOption(&ns_,
"-ns",
"--num-shifts",
65 args.
AddOption(&order_,
"-o",
"--mesh-order",
66 "Order (polynomial degree) of the mesh elements.");
67 args.
AddOption(&ser_ref_levels,
"-rs",
"--refine-serial",
68 "Number of times to refine the mesh uniformly in serial.");
69 args.
AddOption(&R_,
"-R",
"--major-radius",
70 "Major radius of the torus.");
71 args.
AddOption(&r_,
"-r",
"--minor-radius",
72 "Minor radius of the torus.");
73 args.
AddOption(&theta0_,
"-t0",
"--initial-angle",
74 "Starting angle of the cross section (in degrees).");
75 args.
AddOption(&el_type,
"-e",
"--element-type",
76 "Element type: 0 - Wedge, 1 - Hexahedron.");
77 args.
AddOption(&dg_mesh,
"-dm",
"--discont-mesh",
"-cm",
"--cont-mesh",
78 "Use discontinuous or continuous space for the mesh nodes.");
79 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
81 "Enable or disable GLVis visualization.");
91 el_type_ = (el_type == 0) ? Element::WEDGE : Element::HEXAHEDRON;
92 if (el_type_ != Element::WEDGE && el_type_ != Element::HEXAHEDRON)
94 cout <<
"Unsupported element type" << endl;
99 int nnode = (el_type_ == Element::WEDGE)? 3:4;
100 int nshift = (ns_ >= 0) ? 0 : (nnode * (1 - ns_ / nnode));
103 theta0_ *= M_PI / 180.0;
107 mesh =
new Mesh(3, nnode * (nphi_+1), nphi_);
111 for (
int i=0; i<=nphi_; i++)
113 c[0] = 0.0; c[1] = 0.0; c[2] = i;
119 if (el_type_ == Element::HEXAHEDRON)
121 c[0] = 1.0; c[1] = 1.0;
125 c[0] = 0.0; c[1] = 1.0;
131 for (
int i=0; i < nphi_; i++)
133 if (el_type_ == Element::WEDGE)
135 for (
int j = 0; j < 6; j++) { v[j] = 3*i+j; }
140 for (
int j = 0; j < 8; j++) { v[j] = 4*i+j; }
156 for (
int i = 0; i < v2v.Size() - nnode; i++)
161 for (
int i=0; i<nnode; i++)
163 v2v[v2v.Size() - nnode + i] = (nshift + ns_ + i) % nnode;
166 for (
int i = 0; i < mesh->
GetNE(); i++)
171 for (
int j = 0; j < nv; j++)
177 for (
int i = 0; i < mesh->
GetNBE(); i++)
182 for (
int j = 0; j < nv; j++)
192 mesh->
SetCurvature(order_, dg_mesh, 3, Ordering::byVDIM);
196 for (
int lev = 0; lev < ser_ref_levels; lev++)
204 if (el_type_ == Element::WEDGE)
206 oss <<
"toroid-wedge";
212 oss <<
"-o" << order_ <<
"-s" << ns_;
213 if (ser_ref_levels > 0)
215 oss <<
"-r" << ser_ref_levels;
218 ofstream ofs(oss.str().c_str());
227 char vishost[] =
"localhost";
230 sol_sock.precision(8);
231 sol_sock <<
"mesh\n" << *mesh << flush;
241 int nnode = (el_type_ == Element::WEDGE)? 3:4;
243 double phi = 2.0 * M_PI * x[2] / nphi_;
244 double theta = theta0_ + phi * ns_ / nnode;
246 double u = (1.5 * (x[0] + x[1]) - 1.0) * r_;
247 double v = sqrt(0.75) * (x[0] - x[1]) * r_;
249 if (el_type_ == Element::WEDGE)
251 u = (1.5 * (x[0] + x[1]) - 1.0) * r_;
252 v = sqrt(0.75) * (x[0] - x[1]) * r_;
256 u = M_SQRT2 * (x[1] - 0.5) * r_;
257 v = M_SQRT2 * (x[0] - 0.5) * r_;
260 p[0] = ( R_ + u * cos(theta) + v * sin(theta)) * cos(phi);
261 p[1] = ( R_ + u * cos(theta) + v * sin(theta)) * sin(phi);
262 p[2] = v * cos(theta) - u * sin(theta);
void AddHex(const int *vi, int attr=1)
virtual void Print(std::ostream &out=mfem::out) const
virtual void GetVertices(Array< int > &v) const =0
Returns element's vertices.
int GetNBE() const
Returns number of boundary elements.
void Transform(void(*f)(const Vector &, Vector &))
int GetNE() const
Returns number of elements.
int main(int argc, char *argv[])
void RemoveInternalBoundaries()
void AddVertex(const double *)
void UniformRefinement(int i, const DSTable &, int *, int *, int *)
virtual void SetCurvature(int order, bool discont=false, int space_dim=-1, int ordering=1)
Type
Constants for the classes derived from Element.
const Element * GetElement(int i) const
void PrintUsage(std::ostream &out) const
void trans(const Vector &x, Vector &p)
void RemoveUnusedVertices()
Remove unused vertices and rebuild mesh connectivity.
void FinalizeTopology(bool generate_bdr=true)
Finalize the construction of the secondary topology (connectivity) data of a Mesh.
void AddOption(bool *var, const char *enable_short_name, const char *enable_long_name, const char *disable_short_name, const char *disable_long_name, const char *description, bool required=false)
void AddWedge(const int *vi, int attr=1)
int GetNV() const
Returns number of vertices. Vertices are only at the corners of elements, where you would expect them...
void PrintOptions(std::ostream &out) const
virtual int GetNVertices() const =0
void pts(int iphi, int t, double x[])
Abstract data type element.
const Element * GetBdrElement(int i) const