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;
132 for (
int i=0; i < nphi_; i++)
134 if (el_type_ == Element::WEDGE)
136 for (
int j = 0; j < 6; j++) { v[j] = 3*i+j; }
141 for (
int j = 0; j < 8; j++) { v[j] = 4*i+j; }
158 for (
int i = 0; i < v2v.Size() - nnode; i++)
163 for (
int i=0; i<nnode; i++)
165 v2v[v2v.Size() - nnode + i] = (nshift + ns_ + i) % nnode;
168 for (
int i = 0; i < mesh->
GetNE(); i++)
173 for (
int j = 0; j < nv; j++)
179 for (
int i = 0; i < mesh->
GetNBE(); i++)
184 for (
int j = 0; j < nv; j++)
194 mesh->
SetCurvature(order_, dg_mesh, 3, Ordering::byVDIM);
198 for (
int lev = 0; lev < ser_ref_levels; lev++)
206 if (el_type_ == Element::WEDGE)
208 oss <<
"toroid-wedge";
214 oss <<
"-o" << order_ <<
"-s" << ns_;
215 if (ser_ref_levels > 0)
217 oss <<
"-r" << ser_ref_levels;
220 ofstream ofs(oss.str().c_str());
232 sol_sock.precision(8);
233 sol_sock <<
"mesh\n" << *mesh << flush;
243 int nnode = (el_type_ == Element::WEDGE)? 3:4;
245 double phi = 2.0 * M_PI * x[2] / nphi_;
246 double theta = theta0_ + phi * ns_ / nnode;
248 double u = (1.5 * (x[0] + x[1]) - 1.0) * r_;
249 double v = sqrt(0.75) * (x[0] - x[1]) * r_;
251 if (el_type_ == Element::WEDGE)
253 u = (1.5 * (x[0] + x[1]) - 1.0) * r_;
254 v = sqrt(0.75) * (x[0] - x[1]) * r_;
258 u = M_SQRT2 * (x[1] - 0.5) * r_;
259 v = M_SQRT2 * (x[0] - 0.5) * r_;
262 p[0] = ( R_ +
u * cos(theta) + v * sin(theta)) * cos(phi);
263 p[1] = ( R_ +
u * cos(theta) + v * sin(theta)) * sin(phi);
264 p[2] = v * cos(theta) -
u * sin(theta);
void trans(const Vector &u, Vector &x)
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.
void RemoveInternalBoundaries()
int AddVertex(double x, double y=0.0, double z=0.0)
void Parse()
Parse the command-line options. Note that this function expects all the options provided through the ...
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
Print the usage message.
double p(const Vector &x, double t)
void RemoveUnusedVertices()
Remove unused vertices and rebuild mesh connectivity.
int AddHex(int v1, int v2, int v3, int v4, int v5, int v6, int v7, int v8, int attr=1)
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)
Add a boolean option and set 'var' to receive the value. Enable/disable tags are used to set the bool...
int GetNV() const
Returns number of vertices. Vertices are only at the corners of elements, where you would expect them...
virtual void Print(std::ostream &os=mfem::out) const
void PrintOptions(std::ostream &out) const
Print the options.
virtual int GetNVertices() const =0
int AddWedge(int v1, int v2, int v3, int v4, int v5, int v6, int attr=1)
void pts(int iphi, int t, double x[])
double u(const Vector &xvec)
Abstract data type element.
const Element * GetBdrElement(int i) const
bool Good() const
Return true if the command line options were parsed successfully.