48static real_t theta0_ = 0.0;
53int main(
int argc,
char *argv[])
55 int ser_ref_levels = 0;
59 bool visualization =
true;
62 args.
AddOption(&nphi_,
"-nphi",
"--num-elements-phi",
63 "Number of elements in phi-direction.");
64 args.
AddOption(&ns_,
"-ns",
"--num-shifts",
66 args.
AddOption(&order_,
"-o",
"--mesh-order",
67 "Order (polynomial degree) of the mesh elements.");
68 args.
AddOption(&ser_ref_levels,
"-rs",
"--refine-serial",
69 "Number of times to refine the mesh uniformly in serial.");
70 args.
AddOption(&R_,
"-R",
"--major-radius",
71 "Major radius of the torus.");
72 args.
AddOption(&r_,
"-r",
"--minor-radius",
73 "Minor radius of the torus.");
74 args.
AddOption(&theta0_,
"-t0",
"--initial-angle",
75 "Starting angle of the cross section (in degrees).");
76 args.
AddOption(&el_type,
"-e",
"--element-type",
77 "Element type: 0 - Wedge, 1 - Hexahedron.");
78 args.
AddOption(&dg_mesh,
"-dm",
"--discont-mesh",
"-cm",
"--cont-mesh",
79 "Use discontinuous or continuous space for the mesh nodes.");
80 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
82 "Enable or disable GLVis visualization.");
83 args.
AddOption(&visport,
"-p",
"--send-port",
"Socket for GLVis.");
96 cout <<
"Unsupported element type" << endl;
102 int nshift = (ns_ >= 0) ? 0 : (nnode * (1 - ns_ / nnode));
105 theta0_ *= M_PI / 180.0;
109 mesh =
new Mesh(3, nnode * (nphi_+1), nphi_);
113 for (
int i=0; i<=nphi_; i++)
115 c[0] = 0.0; c[1] = 0.0; c[2] = i;
123 c[0] = 1.0; c[1] = 1.0;
127 c[0] = 0.0; c[1] = 1.0;
134 for (
int i=0; i < nphi_; i++)
138 for (
int j = 0; j < 6; j++) { v[j] = 3*i+j; }
143 for (
int j = 0; j < 8; j++) { v[j] = 4*i+j; }
160 for (
int i = 0; i < v2v.
Size() - nnode; i++)
165 for (
int i=0; i<nnode; i++)
167 v2v[v2v.
Size() - nnode + i] = (nshift + ns_ + i) % nnode;
170 for (
int i = 0; i < mesh->
GetNE(); i++)
175 for (
int j = 0; j < nv; j++)
181 for (
int i = 0; i < mesh->
GetNBE(); i++)
186 for (
int j = 0; j < nv; j++)
200 for (
int lev = 0; lev < ser_ref_levels; lev++)
210 oss <<
"toroid-wedge";
216 oss <<
"-o" << order_ <<
"-s" << ns_;
217 if (ser_ref_levels > 0)
219 oss <<
"-r" << ser_ref_levels;
222 ofstream ofs(oss.str().c_str());
233 sol_sock.precision(8);
234 sol_sock <<
"mesh\n" << *mesh << flush;
246 real_t phi = 2.0 * M_PI * x[2] / nphi_;
247 real_t theta = theta0_ + phi * ns_ / nnode;
249 real_t u = (1.5 * (x[0] + x[1]) - 1.0) * r_;
250 real_t v = sqrt(0.75) * (x[0] - x[1]) * r_;
254 u = (1.5 * (x[0] + x[1]) - 1.0) * r_;
255 v = sqrt(0.75) * (x[0] - x[1]) * r_;
259 u = M_SQRT2 * (x[1] - 0.5) * r_;
260 v = M_SQRT2 * (x[0] - 0.5) * r_;
263 p[0] = ( R_ +
u * cos(theta) + v * sin(theta)) * cos(phi);
264 p[1] = ( R_ +
u * cos(theta) + v * sin(theta)) * sin(phi);
265 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[])