48static real_t theta0_ = 0.0;
53int 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.");
94 cout <<
"Unsupported element type" << endl;
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;
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++)
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++)
198 for (
int lev = 0; lev < ser_ref_levels; lev++)
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;
245 real_t phi = 2.0 * M_PI * x[2] / nphi_;
246 real_t theta = theta0_ + phi * ns_ / nnode;
248 real_t u = (1.5 * (x[0] + x[1]) - 1.0) * r_;
249 real_t v = sqrt(0.75) * (x[0] - x[1]) * r_;
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);
int Size() const
Return the logical size of the array.
Abstract data type element.
virtual void GetVertices(Array< int > &v) const =0
Get the indices defining the vertices.
Type
Constants for the classes derived from Element.
virtual int GetNVertices() const =0
int AddWedge(int v1, int v2, int v3, int v4, int v5, int v6, int attr=1)
Adds a wedge to the mesh given by 6 vertices v1 through v6.
const Element * GetElement(int i) const
Return pointer to the i'th element object.
void FinalizeTopology(bool generate_bdr=true)
Finalize the construction of the secondary topology (connectivity) data of a Mesh.
virtual void Print(std::ostream &os=mfem::out, const std::string &comments="") const
int AddVertex(real_t x, real_t y=0.0, real_t z=0.0)
int GetNE() const
Returns number of elements.
const Element * GetBdrElement(int i) const
Return pointer to the i'th boundary element object.
int GetNV() const
Returns number of vertices. Vertices are only at the corners of elements, where you would expect them...
int AddHex(int v1, int v2, int v3, int v4, int v5, int v6, int v7, int v8, int attr=1)
Adds a hexahedron to the mesh given by 8 vertices v1 through v8.
int GetNBE() const
Returns number of boundary elements.
virtual void SetCurvature(int order, bool discont=false, int space_dim=-1, int ordering=1)
Set the curvature of the mesh nodes using the given polynomial degree.
void Transform(void(*f)(const Vector &, Vector &))
void UniformRefinement(int i, const DSTable &, int *, int *, int *)
void RemoveInternalBoundaries()
void RemoveUnusedVertices()
Remove unused vertices and rebuild mesh connectivity.
void Parse()
Parse the command-line options. Note that this function expects all the options provided through the ...
void PrintUsage(std::ostream &out) const
Print the usage message.
void PrintOptions(std::ostream &out) const
Print the options.
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...
bool Good() const
Return true if the command line options were parsed successfully.
real_t u(const Vector &xvec)
real_t p(const Vector &x, real_t t)
void trans(const Vector &x, Vector &p)
void pts(int iphi, int t, real_t x[])