39 int main(
int argc,
char *argv[])
41 const char *new_mesh_file =
"klein-bottle.mesh";
47 bool visualization =
true;
50 args.
AddOption(&new_mesh_file,
"-m",
"--mesh-out-file",
51 "Output Mesh file to write.");
52 args.
AddOption(&nx,
"-nx",
"--num-elements-x",
53 "Number of elements in x-direction.");
54 args.
AddOption(&ny,
"-ny",
"--num-elements-y",
55 "Number of elements in y-direction.");
56 args.
AddOption(&order,
"-o",
"--mesh-order",
57 "Order (polynomial degree) of the mesh elements.");
58 args.
AddOption(&trans_type,
"-t",
"--transformation-type",
59 "Set the transformation type: 0 - \"figure-8\"," 60 " 1 - \"bottle\", 2 - \"bottle2\".");
61 args.
AddOption(&dg_mesh,
"-dm",
"--discont-mesh",
"-cm",
"--cont-mesh",
62 "Use discontinuous or continuous space for the mesh nodes.");
63 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
65 "Enable or disable GLVis visualization.");
77 Mesh mesh = Mesh::MakeCartesian2D(nx, ny, el_type, 1, 2*M_PI, 2*M_PI);
83 for (
int i = 0; i < v2v.Size(); i++)
88 for (
int i = 0; i <= nx; i++)
90 int v_old = i + ny * (nx + 1);
95 for (
int j = 0; j <= ny; j++)
97 int v_old = nx + j * (nx + 1);
98 int v_new = (ny - j) * (nx + 1);
99 v2v[v_old] = v2v[v_new];
102 for (
int i = 0; i < mesh.
GetNE(); i++)
107 for (
int j = 0; j < nv; j++)
113 for (
int i = 0; i < mesh.
GetNBE(); i++)
118 for (
int j = 0; j < nv; j++)
141 for (
int i = 0; i < nodes.
Size(); i++)
143 if (std::abs(nodes(i)) < 1e-12)
149 ofstream ofs(new_mesh_file);
159 sol_sock.precision(8);
160 sol_sock <<
"mesh\n" << mesh << flush;
168 const double r = 2.5;
169 double a = r + cos(x(0)/2) * sin(x(1)) - sin(x(0)/2) * sin(2*x(1));
172 p(0) =
a * cos(x(0));
173 p(1) =
a * sin(x(0));
174 p(2) = sin(x(0)/2) * sin(x(1)) + cos(x(0)/2) * sin(2*x(1));
180 double v = x(1) + M_PI_2;
181 double a = 6.*cos(
u)*(1.+sin(
u));
182 double b = 16.*sin(
u);
183 double r = 4.*(1.-cos(
u)/2.);
187 p(0) =
a+r*cos(
u)*cos(v);
188 p(1) =
b+r*sin(
u)*cos(v);
192 p(0) =
a+r*cos(v+M_PI);
200 double u = x(1)-M_PI_2, v = 2*x(0);
201 const double pi = M_PI;
203 p(0) = (v<pi ? (2.5-1.5*cos(v))*cos(
u) :
204 (v<2*pi ? (2.5-1.5*cos(v))*cos(
u) :
205 (v<3*pi ? -2+(2+cos(
u))*cos(v) : -2+2*cos(v)-cos(
u))));
206 p(1) = (v<pi ? (2.5-1.5*cos(v))*sin(
u) :
207 (v<2*pi ? (2.5-1.5*cos(v))*sin(
u) :
208 (v<3*pi ? sin(
u) : sin(
u))));
209 p(2) = (v<pi ? -2.5*sin(v) :
211 (v<3*pi ? (2+cos(
u))*sin(v)+3*pi : -3*v+12*pi)));
void bottle2_trans(const Vector &x, Vector &p)
Class for grid function - Vector with associated FE space.
virtual void GetVertices(Array< int > &v) const =0
Returns element's vertices.
void PrintOptions(std::ostream &out) const
Print the options.
void PrintUsage(std::ostream &out) const
Print the usage message.
int Size() const
Returns the size of the vector.
void Transform(void(*f)(const Vector &, Vector &))
const Element * GetElement(int i) const
bool Good() const
Return true if the command line options were parsed successfully.
void RemoveInternalBoundaries()
int GetNBE() const
Returns number of boundary elements.
void figure8_trans(const Vector &x, Vector &p)
int GetNV() const
Returns number of vertices. Vertices are only at the corners of elements, where you would expect them...
void Parse()
Parse the command-line options. Note that this function expects all the options provided through the ...
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.
Type
Constants for the classes derived from Element.
double p(const Vector &x, double t)
void RemoveUnusedVertices()
Remove unused vertices and rebuild mesh connectivity.
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 main(int argc, char *argv[])
int GetNE() const
Returns number of elements.
virtual int GetNVertices() const =0
virtual void Print(std::ostream &os=mfem::out) const
void GetNodes(Vector &node_coord) const
double u(const Vector &xvec)
const Element * GetBdrElement(int i) const
void bottle_trans(const Vector &x, Vector &p)
Abstract data type element.