45 int main(
int argc,
char *argv[])
50 bool visualization =
true;
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.");
60 "Frequency of the x-component.");
62 "Frequency of the y-component.");
64 "Phase angle of the x-component.");
65 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
67 "Enable or disable GLVis visualization.");
76 delta *= M_PI / 180.0;
83 Mesh mesh = Mesh::MakeCartesian2D(
84 nx, ny, Element::QUADRILATERAL, 1, 2*M_PI, 2*M_PI);
96 soutv.
open(vishost, visport);
97 soutv <<
"solution\n" << mesh <<
u;
98 soutv <<
"keys 'ARRj" << std::string(90,
'7') <<
"'\n";
99 soutv <<
"palette 17 zoom 1.65 subdivisions 32 0\n";
100 soutv <<
"window_title 'V' window_geometry 0 0 500 500\n";
106 Mesh mesh = Mesh::MakeCartesian2D(
107 nx, ny, Element::QUADRILATERAL, 1, 2*M_PI, 2*M_PI);
119 south.
open(vishost, visport);
120 south <<
"solution\n" << mesh <<
u;
121 south <<
"keys 'ARRj'\n";
122 south <<
"palette 17 zoom 1.65 subdivisions 32 0\n";
123 south <<
"window_title 'H' window_geometry 500 0 500 500\n";
127 ofstream mesh_ofs(
"lissajous.mesh");
128 mesh_ofs.precision(8);
129 mesh.
Print(mesh_ofs);
130 ofstream sol_ofs(
"lissajous.gf");
131 sol_ofs.precision(8);
135 soutv <<
"keys '.0" << std::string((
int)
b,
'0') <<
"'\n" << flush;
136 south <<
"keys '.0" << std::string((
int)
a,
'0') <<
"'\n" << flush;
138 cout <<
"Which direction(s) are the two curves spinning in?\n";
151 double a_,
double b_,
double delta_)
165 p[2] = A*sin(a_*t + delta_);
170 double R = 0.02*(A+B);
173 double normal[3] = { cos(b_*t), sin(b_*t), 0 };
180 double cross[3] = { A*a_*sin(b_*t)*cos(a_*t+delta_), -A*a_*cos(b_*t)*cos(a_*t+delta_), b_*B };
181 for (
int i = 0; i < 3; i++) { cn += cross[i]*cross[i]; }
182 for (
int i = 0; i < 3; i++) { cross[i] /= sqrt(cn); }
186 for (
int i = 0; i < 3; i++)
188 p[i] += R * (cos(theta)*normal[i] + sin(theta)*cross[i]);
void lissajous_trans_h(const Vector &x, Vector &p)
Class for grid function - Vector with associated FE space.
void SetSize(int s)
Resize the vector to size s.
void Transform(void(*f)(const Vector &, Vector &))
void lissajous_trans_v(const Vector &x, Vector &p)
virtual void Save(std::ostream &out) const
Save the GridFunction to an output stream.
double u_function(const Vector &x)
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)
void PrintUsage(std::ostream &out) const
Print the usage message.
double p(const Vector &x, double t)
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
void lissajous_trans(const Vector &x, Vector &p, double a_, double b_, double delta_)
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...
virtual void Print(std::ostream &os=mfem::out) const
void PrintOptions(std::ostream &out) const
Print the options.
virtual void ProjectCoefficient(Coefficient &coeff)
Project coeff Coefficient to this GridFunction. The projection computation depends on the choice of t...
int open(const char hostname[], int port)
Open the socket stream on 'port' at 'hostname'.
A general function coefficient.
Arbitrary order H1-conforming (continuous) finite elements.
double u(const Vector &xvec)
bool Good() const
Return true if the command line options were parsed successfully.