41int main(
int argc,
char *argv[])
44 string mfem_data_dir =
"../../../data";
49 bool visualization =
true;
52 args.
AddOption(&mfem_data_dir,
"-data",
"--mfem_data_dir",
53 "Path to the mfem/data repo (required). Clone it from:\n"
54 "\t\thttps://github.com/mfem/data");
55 args.
AddOption(&conf,
"-c",
"--configuration",
56 "Which configuration of the two parts to animate.\n"
57 "\tThere are 8 options denoted as P1 -> P2 for part P1\n"
58 "\tpassing through part P2, using the following notation:\n"
59 "\tI/O = inner/outer part, S/F = sharp/flat end.\n"
60 "\t\t1) OS -> IS 5) IS -> OS \n"
61 "\t\t2) OF -> IS 6) IS -> OF \n"
62 "\t\t3) OS -> IF 7) IF -> OS \n"
63 "\t\t4) OF -> IF 8) IF -> OF ");
65 "Number of visualization steps in the animation.");
66 args.
AddOption(&color,
"-col",
"--color",
"-no-col",
"--no-color",
67 "Visualize the parts with different colors.");
68 args.
AddOption(&movie,
"-mov",
"--movie",
"-no-mov",
"--no-movie",
69 "Ask GLVis to take screenshots to make a movie.");
70 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
72 "Enable or disable GLVis visualization.");
82 string mesh_file = mfem_data_dir +
"/vtk/spiral-toy.vtk";
83 ifstream file(mesh_file);
86 cout <<
"Can't find the mesh file '" << mesh_file <<
"'\n"
87 <<
"Make sure the github.com/mfem/data repository is cloned in '"
88 << mfem_data_dir <<
"'\n";
93 if (conf < 1 || conf > 8)
95 cerr <<
"Configuration option should be between 1 and 8. Setting to 1.\n";
100 Mesh mesh(mfem_data_dir+
"/vtk/spiral-toy.vtk", 1, 1);
106 for (
int i = 0; i < mesh.
GetNV(); i++)
109 part[i] = (v[1] < -26.55) ? 1.0 : 2.0;
113 for (
int i = 0; i < mesh.
GetNE(); i++)
126 for (
int d = 0; d <= steps; d++)
133 if (conf == 1 || conf == 5)
135 phi = -(10 * frac + 3.7);
137 if (conf == 2 || conf == 6)
139 phi = -(10 * frac + 2.8);
141 if (conf == 3 || conf == 7)
143 phi = -(10 * frac + 2.8);
145 if (conf == 4 || conf == 8)
147 phi = -(10 * frac + 3.2);
153 for (
int i = 0; i < mesh.
GetNV(); i++)
165 if (conf == 1 || conf == 3 || conf == 5 || conf == 7)
169 v2 = 133.4 - 133.4*frac - v[2];
172 if (conf == 2 || conf == 4 || conf == 6 || conf == 8)
176 v2 = 73.04 - 133.4*frac + v[2];
179 if (conf == 1 || conf == 2 || conf == 3 || conf == 4)
181 v[0] = cos(phi)*v0 - sin(phi)*v1;
182 v[1] = sin(phi)*v0 + cos(phi)*v1;
186 if (conf == 5 || conf == 6 || conf == 7 || conf == 8)
197 if (conf == 3 || conf == 4)
203 if (conf == 5 || conf == 6)
207 v[0] = cos(phi)*v0 - sin(phi)*v1;
208 v[1] = sin(phi)*v0 + cos(phi)*v1;
212 if (conf == 7 || conf == 8)
216 v[0] = cos(phi)*v0 - sin(phi)*v1;
217 v[1] = sin(phi)*v0 + cos(phi)*v1;
229 sol_sock.precision(8);
233 sol_sock <<
"solution\n" << mesh2 << part
234 <<
"keys A\n" <<
"palette 16\n";
238 sol_sock <<
"mesh\n" << mesh2
239 <<
"keys maaappppppptA\n" <<
"palette 12\n";
242 sol_sock <<
"window_geometry 0 0 500 1000\n"
243 <<
"zoom 3\n" <<
"autoscale on\n" <<
"pause\n";
245 cout <<
"To see the animation, press 'space' in the GLVis window\n";
251 sol_sock <<
"solution\n" << mesh2 << part;
255 sol_sock <<
"mesh\n" << mesh2;
261 sol_sock <<
"screenshot spiral"
262 << setfill(
'0') << setw(3) << d <<
".png\n";
271 cout <<
"A sequence of screenshot files: spiral000.png ... spiral"
272 << setfill(
'0') << setw(3) << steps <<
".png\n"
273 <<
"have been saved in the directory from which GLVis is running.\n";
41int main(
int argc,
char *argv[]) {
…}
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
Class for grid function - Vector with associated FE space.
Arbitrary order H1-conforming (continuous) finite elements.
void SetAttribute(int i, int attr)
Set the attribute of element i.
int GetNE() const
Returns number of elements.
int GetNV() const
Returns number of vertices. Vertices are only at the corners of elements, where you would expect them...
void GetElementCenter(int i, Vector ¢er)
const real_t * GetVertex(int i) const
Return pointer to vertex i's coordinates.
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.
int open(const char hostname[], int port)
Open the socket stream on 'port' at 'hostname'.