42 for (
int i = 0; i < x.
Size(); i++)
44 x(i) = (x(i)-xmin(i))/(xmax(i)-xmin(i));
47 double col = x(0), row = x(1);
49 int width = 1080, height = 1080;
52 double c_re = (col - width/2)*4.0/width;
53 double c_im = (row - height/2)*4.0/width;
55 int iteration = 0, maxit = 10000;
56 while (x*x+y*y <= 4 && iteration < maxit)
58 double x_new = x*x - y*y + c_re;
63 if (iteration < maxit)
65 return iteration%10+2;
74 int main(
int argc,
char *argv[])
76 const char *mesh_file =
"../../data/inline-quad.mesh";
80 bool visualization = 1;
84 args.
AddOption(&mesh_file,
"-m",
"--mesh",
85 "Input mesh file to shape materials in.");
86 args.
AddOption(&sd,
"-sd",
"--sub-divisions",
87 "Number of element subdivisions for interface detection.");
88 args.
AddOption(&nclimit,
"-ncl",
"--nc-limit",
89 "Level of hanging nodes allowed (-1 = unlimited).");
90 args.
AddOption(&aniso,
"-a",
"--aniso",
"-i",
"--iso",
91 "Enable anisotropic refinement of quads and hexes.");
92 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
94 "Enable or disable GLVis visualization.");
100 Mesh mesh(mesh_file, 1, 1);
126 sol_sock.
open(vishost, visport);
127 sol_sock.precision(8);
131 for (
int iter = 0; 1; iter++)
134 for (
int i = 0; i < mesh.
GetNE(); i++)
156 if ((
int)matsum != m*(j+1))
173 int dx = 0, dy = 0, dz = 0;
177 for (
int j = 0; j <= sd; j++)
178 for (
int i = 0; i < sd; i++)
180 dx += abs(mat[j*s + i+1] - mat[j*s + i]);
181 dy += abs(mat[(i+1)*s + j] - mat[i*s + j]);
186 for (
int k = 0; k <= sd; k++)
187 for (
int j = 0; j <= sd; j++)
188 for (
int i = 0; i < sd; i++)
190 dx += abs(mat[(k*s + j)*s + i+1] - mat[(k*s + j)*s + i]);
191 dy += abs(mat[(k*s + i+1)*s + j] - mat[(k*s + i)*s + j]);
192 dz += abs(mat[((i+1)*s + j)*s + k] - mat[(i*s + j)*s + k]);
196 const int tol = mat.Size() / 10;
197 if (dx > tol) { type |= 1; }
198 if (dy > tol) { type |= 2; }
199 if (dz > tol) { type |= 4; }
200 if (!type) { type = 7; }
210 sol_sock <<
"solution\n" << mesh << attr;
211 if (iter == 0 && sdim == 2)
213 sol_sock <<
"keys 'RjlppppppppppppppA*************'\n";
215 if (iter == 0 && sdim == 3)
217 sol_sock <<
"keys 'YYYYYYYYYXXXXXXXmA********8888888pppttt";
218 if (dim == 3) { sol_sock <<
"iiM"; }
225 cout <<
"Iteration " << iter+1 <<
": mesh has " << mesh.
GetNE() <<
227 if ((iter+1) % 4 == 0)
229 if (!visualization) {
break; }
231 cout <<
"Continue shaping? --> ";
233 if (yn ==
'n' || yn ==
'q') {
break; }
243 for (
int i = 0; i < mesh.
GetNE(); i++)
250 ofstream mesh_ofs(
"mandel.mesh");
251 mesh_ofs.precision(8);
252 mesh.
Print(mesh_ofs);
int GetNPoints() const
Returns the number of the points in the integration rule.
virtual void Print(std::ostream &out=mfem::out) const
Class for an integration rule - an Array of IntegrationPoint.
Class for grid function - Vector with associated FE space.
virtual void Update(bool want_transform=true)
Reflect changes in the mesh: update number of DOFs, etc. Also, calculate GridFunction transformation ...
void GetBoundingBox(Vector &min, Vector &max, int ref=2)
Returns the minimum and maximum corners of the mesh bounding box.
int Size() const
Returns the size of the vector.
int GetNE() const
Returns number of elements.
int main(int argc, char *argv[])
Geometry::Type GetElementBaseGeometry(int i) const
IntegrationPoint & IntPoint(int i)
Returns a reference to the i-th integration point.
int material(Vector &x, Vector &xmin, Vector &xmax)
void Parse()
Parse the command-line options. Note that this function expects all the options provided through the ...
virtual void SetAttributes()
int Append(const T &el)
Append element 'el' to array, resize if necessary.
void UniformRefinement(int i, const DSTable &, int *, int *, int *)
virtual void SetCurvature(int order, bool discont=false, int space_dim=-1, int ordering=1)
int MeshGenerator()
Get the mesh generator/type.
GeometryRefiner GlobGeometryRefiner
RefinedGeometry * Refine(Geometry::Type Geom, int Times, int ETimes=1)
void PrintUsage(std::ostream &out) const
Print the usage message.
int SpaceDimension() const
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
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 Update()
Transform by the Space UpdateMatrix (e.g., on Mesh change).
NURBSExtension * NURBSext
Optional NURBS mesh extension.
void GetElementTransformation(int i, IsoparametricTransformation *ElTr)
void PrintOptions(std::ostream &out) const
Print the options.
int open(const char hostname[], int port)
Open the socket stream on 'port' at 'hostname'.
void SetAttribute(int i, int attr)
Set the attribute of element i.
void GeneralRefinement(const Array< Refinement > &refinements, int nonconforming=-1, int nc_limit=0)
Arbitrary order "L2-conforming" discontinuous finite elements.
bool Good() const
Return true if the command line options were parsed successfully.