55 static double p = 2.0;
58 for (
int i = 0; i < x.
Size(); i++)
60 x(i) = (2*x(i)-xmin(i)-xmax(i))/(xmax(i)-xmin(i));
64 if (x.
Normlp(p) > 0.4 && x.
Normlp(p) < 0.6) {
return 1; }
65 if (x.
Normlp(p) < 0.4 || x.
Normlp(p) > 0.6) {
return 2; }
69 int main(
int argc,
char *argv[])
73 const char *mesh_file =
"../../data/inline-quad.mesh";
78 args.
AddOption(&mesh_file,
"-m",
"--mesh",
79 "Input mesh file to shape materials in.");
80 args.
AddOption(&sd,
"-sd",
"--sub-divisions",
81 "Number of element subdivisions for interface detection.");
82 args.
AddOption(&nclimit,
"-ncl",
"--nc-limit",
83 "Level of hanging nodes allowed (-1 = unlimited).");
84 args.
AddOption(&aniso,
"-a",
"--aniso",
"-i",
"--iso",
85 "Enable anisotropic refinement of quads and hexes.");
91 Mesh mesh(mesh_file, 1, 1);
112 sol_sock.precision(8);
115 for (
int iter = 0; 1; iter++)
118 for (
int i = 0; i < mesh.
GetNE(); i++)
140 if ((
int)matsum != m*(j+1))
157 int dx = 0, dy = 0, dz = 0;
161 for (
int jj = 0; jj <= sd; jj++)
162 for (
int ii = 0; ii < sd; ii++)
164 dx += abs(mat[jj*s + ii+1] - mat[jj*s + ii]);
165 dy += abs(mat[(ii+1)*s + jj] - mat[ii*s + jj]);
170 for (
int kk = 0; kk <= sd; kk++)
171 for (
int jj = 0; jj <= sd; jj++)
172 for (
int ii = 0; ii < sd; ii++)
174 dx += abs(mat[(kk*s + jj)*s + ii+1] - mat[(kk*s + jj)*s + ii]);
175 dy += abs(mat[(kk*s + ii+1)*s + jj] - mat[(kk*s + ii)*s + jj]);
176 dz += abs(mat[((ii+1)*s + jj)*s + kk] - mat[(ii*s + jj)*s + kk]);
180 const int tol = mat.Size() / 10;
181 if (dx > tol) { type |= 1; }
182 if (dy > tol) { type |= 2; }
183 if (dz > tol) { type |= 4; }
184 if (!type) { type = 7; }
192 sol_sock <<
"solution\n" << mesh << attr;
193 if (iter == 0 && sdim == 2)
195 sol_sock <<
"keys 'RjlmpppppppppppppA*************'\n";
197 if (iter == 0 && sdim == 3)
199 sol_sock <<
"keys 'YYYYYYYYYXXXXXXXmA********8888888pppttt";
200 if (dim == 3) { sol_sock <<
"iiM"; }
207 cout <<
"Mesh has " << mesh.
GetNE() <<
" elements. \n"
208 <<
"Continue shaping? --> ";
210 if (yn ==
'n' || yn ==
'q') {
break; }
219 for (
int i = 0; i < mesh.
GetNE(); i++)
226 ofstream mesh_ofs(
"shaper.mesh");
227 mesh_ofs.precision(8);
228 mesh.
Print(mesh_ofs);
int GetNPoints() const
Returns the number of the points in the integration rule.
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.
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)
double Normlp(double p) const
Returns the l_p norm of the vector.
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.
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
double p(const Vector &x, double t)
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...
NURBSExtension * NURBSext
Optional NURBS mesh extension.
void GetElementTransformation(int i, IsoparametricTransformation *ElTr)
virtual void Print(std::ostream &os=mfem::out) const
void PrintOptions(std::ostream &out) const
Print the options.
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.