39int main(
int argc,
char *argv[])
41 const char *new_mesh_file =
"klein-bottle.mesh";
48 bool visualization =
true;
51 args.
AddOption(&new_mesh_file,
"-m",
"--mesh-out-file",
52 "Output Mesh file to write.");
53 args.
AddOption(&nx,
"-nx",
"--num-elements-x",
54 "Number of elements in x-direction.");
55 args.
AddOption(&ny,
"-ny",
"--num-elements-y",
56 "Number of elements in y-direction.");
57 args.
AddOption(&order,
"-o",
"--mesh-order",
58 "Order (polynomial degree) of the mesh elements.");
59 args.
AddOption(&trans_type,
"-t",
"--transformation-type",
60 "Set the transformation type: 0 - \"figure-8\","
61 " 1 - \"bottle\", 2 - \"bottle2\".");
62 args.
AddOption(&dg_mesh,
"-dm",
"--discont-mesh",
"-cm",
"--cont-mesh",
63 "Use discontinuous or continuous space for the mesh nodes.");
64 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
66 "Enable or disable GLVis visualization.");
67 args.
AddOption(&visport,
"-p",
"--send-port",
"Socket for GLVis.");
85 for (
int i = 0; i < v2v.
Size(); i++)
90 for (
int i = 0; i <= nx; i++)
92 int v_old = i + ny * (nx + 1);
97 for (
int j = 0; j <= ny; j++)
99 int v_old = nx + j * (nx + 1);
100 int v_new = (ny - j) * (nx + 1);
101 v2v[v_old] = v2v[v_new];
104 for (
int i = 0; i < mesh.
GetNE(); i++)
109 for (
int j = 0; j < nv; j++)
115 for (
int i = 0; i < mesh.
GetNBE(); i++)
120 for (
int j = 0; j < nv; j++)
143 for (
int i = 0; i <
nodes.Size(); i++)
145 if (std::abs(
nodes(i)) < 1e-12)
151 ofstream ofs(new_mesh_file);
160 sol_sock.precision(8);
161 sol_sock <<
"mesh\n" << mesh << flush;
170 real_t a = r + cos(x(0)/2) * sin(x(1)) - sin(x(0)/2) * sin(2*x(1));
173 p(0) =
a * cos(x(0));
174 p(1) =
a * sin(x(0));
175 p(2) = sin(x(0)/2) * sin(x(1)) + cos(x(0)/2) * sin(2*x(1));
188 p(0) =
a+r*cos(
u)*cos(v);
189 p(1) =
b+r*sin(
u)*cos(v);
193 p(0) =
a+r*cos(v+M_PI);
201 real_t u = x(1)-M_PI_2, v = 2*x(0);
204 p(0) = (v<pi ? (2.5-1.5*cos(v))*cos(
u) :
205 (v<2*pi ? (2.5-1.5*cos(v))*cos(
u) :
206 (v<3*pi ? -2+(2+cos(
u))*cos(v) : -2+2*cos(v)-cos(
u))));
207 p(1) = (v<pi ? (2.5-1.5*cos(v))*sin(
u) :
208 (v<2*pi ? (2.5-1.5*cos(v))*sin(
u) :
209 (v<3*pi ? sin(
u) : sin(
u))));
210 p(2) = (v<pi ? -2.5*sin(v) :
212 (v<3*pi ? (2+cos(
u))*sin(v)+3*pi : -3*v+12*pi)));
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
Class for grid function - Vector with associated FE space.
const Element * GetElement(int i) const
Return pointer to the i'th element object.
virtual void Print(std::ostream &os=mfem::out, const std::string &comments="") const
int GetNE() const
Returns number of elements.
const Element * GetBdrElement(int i) const
Return pointer to the i'th boundary element object.
void GetNodes(Vector &node_coord) const
int GetNV() const
Returns number of vertices. Vertices are only at the corners of elements, where you would expect them...
int GetNBE() const
Returns number of boundary elements.
static Mesh MakeCartesian2D(int nx, int ny, Element::Type type, bool generate_edges=false, real_t sx=1.0, real_t sy=1.0, bool sfc_ordering=true)
Creates mesh for the rectangle [0,sx]x[0,sy], divided into nx*ny quadrilaterals if type = QUADRILATER...
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 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.
void figure8_trans(const Vector &x, Vector &p)
void bottle_trans(const Vector &x, Vector &p)
void bottle2_trans(const Vector &x, Vector &p)
real_t u(const Vector &xvec)
real_t p(const Vector &x, real_t t)
std::array< int, NCMesh::MaxFaceNodes > nodes