26 #include "../common/mfem-common.hpp" 35 int main (
int argc,
char *argv[])
41 const char *mesh_file =
"square01.mesh";
43 int mesh_poly_deg = 2;
49 args.
AddOption(&mesh_file,
"-m",
"--mesh",
51 args.
AddOption(&rs_levels,
"-rs",
"--refine-serial",
52 "Number of times to refine the mesh uniformly in serial.");
53 args.
AddOption(&mesh_poly_deg,
"-o",
"--order",
54 "Polynomial degree of mesh finite element space.");
55 args.
AddOption(&quad_order,
"-qo",
"--quad_order",
56 "Order of the quadrature rule.");
57 args.
AddOption(&glvis,
"-vis",
"--visualization",
"-no-vis",
59 "Enable or disable GLVis visualization.");
69 Mesh *mesh =
new Mesh(mesh_file, 1, 1,
false);
71 ParMesh pmesh(MPI_COMM_WORLD, *mesh);
77 if (mesh_poly_deg <= 0)
97 fit_marker_vis_gf = 0.0;
98 for (
int e = 0; e < pmesh.
GetNBE(); e++)
102 if (attr != 2) {
continue; }
105 for (
int j = 0; j < nd; j++)
107 int j_x = vdofs[j], j_y = vdofs[nd+j];
108 const double x = coord(j_x),
109 z = (
dim == 2) ? 0.0 : coord(vdofs[2*nd + j]);
110 fit_marker[pfes_mesh.
VDofToDof(j_x)] =
true;
111 fit_marker_vis_gf(j_x) = 1.0;
112 if (coord(j_y) < 0.5)
114 coord_target(j_y) = 0.1 * sin(4 * M_PI * x) * cos(M_PI * z);
118 if (coord(j_x) < 0.5)
120 coord_target(j_y) = 1.0 + 0.1 * sin(2 * M_PI * x);
124 coord_target(j_y) = 1.0 + 0.1 * sin(2 * M_PI * (x + 0.5));
135 coord = coord_target;
137 "Target positions (DOFS with value 1)",
138 0, 0, 400, 400, (
dim == 2) ?
"Rjm" :
"");
145 for (
int i = 0; i < pmesh.
GetNBE(); i++)
149 MFEM_VERIFY(!(
dim == 2 && attr == 3),
150 "Boundary attribute 3 must be used only for 3D meshes. " 151 "Adjust the attributes (1/2/3/4 for fixed x/y/z/all " 152 "components, rest for free nodes), or use -fix-bnd.");
153 if (attr == 1 || attr == 3) { n += nd; }
154 if (attr == 4) { n += nd *
dim; }
158 for (
int i = 0; i < pmesh.
GetNBE(); i++)
165 for (
int j = 0; j < nd; j++)
166 { ess_vdofs[n++] = vdofs[j]; }
170 for (
int j = 0; j < nd; j++)
171 { ess_vdofs[n++] = vdofs[j+2*nd]; }
175 for (
int j = 0; j < vdofs.
Size(); j++)
176 { ess_vdofs[n++] = vdofs[j]; }
188 integ->EnableSurfaceFitting(coord_target, fit_marker, fit_weight);
193 minres.SetRelTol(1e-12);
194 minres.SetAbsTol(0.0);
198 a.SetEssentialVDofs(ess_vdofs);
199 a.AddDomainIntegrator(integ);
204 solver.SetPreconditioner(minres);
205 solver.SetPrintLevel(1);
206 solver.SetMaxIter(200);
207 solver.SetRelTol(1e-10);
208 solver.SetAbsTol(0.0);
209 solver.EnableAdaptiveSurfaceFitting();
210 solver.SetTerminationWithMaxSurfaceFittingError(1e-3);
Class for an integration rule - an Array of IntegrationPoint.
const IntegrationRule & Get(int GeomType, int Order)
Returns an integration rule for given GeomType and Order.
void SetFromTrueVector()
Shortcut for calling SetFromTrueDofs() with GetTrueVector() as argument.
A coefficient that is constant across space and time.
virtual void SetOperator(const Operator &op)
Also calls SetOperator for the preconditioner if there is one.
void PrintOptions(std::ostream &out) const
Print the options.
int Dimension() const
Dimension of the reference space used within the elements.
void PrintUsage(std::ostream &out) const
Print the usage message.
int GetAttribute() const
Return element's attribute.
3D barrier Shape (S) metric, well-posed (polyconvex & invex).
int GetNDofs() const
Returns number of degrees of freedom. This is the number of Local Degrees of Freedom.
bool Good() const
Return true if the command line options were parsed successfully.
Abstract parallel finite element space.
int GetNBE() const
Returns number of boundary elements.
IntegrationRules IntRules(0, Quadrature1D::GaussLegendre)
A global object with all integration rules (defined in intrules.cpp)
Geometry::Type GetGeomType() const
Returns the Geometry::Type of the reference element.
Abstract class for local mesh quality metrics in the target-matrix optimization paradigm (TMOP) by P...
void SetTrueVector()
Shortcut for calling GetTrueDofs() with GetTrueVector() as argument.
void Parse()
Parse the command-line options. Note that this function expects all the options provided through the ...
void UniformRefinement(int i, const DSTable &, int *, int *, int *)
void SetMaxIter(int max_it)
Version of QuadraticFECollection with positive basis functions.
static void Init()
Singleton creation with Mpi::Init();.
int main(int argc, char *argv[])
virtual const FiniteElement * GetFE(int i) const
Collection of finite elements from the same family in multiple dimensions. This class is used to matc...
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...
int GetDof() const
Returns the number of degrees of freedom in the finite element.
const Vector & GetTrueVector() const
Read only access to the (optional) internal true-dof Vector.
void VisualizeMesh(socketstream &sock, const char *vishost, int visport, Mesh &mesh, const char *title, int x, int y, int w, int h, const char *keys)
DofTransformation * GetBdrElementVDofs(int i, Array< int > &vdofs) const
Returns indices of degrees of freedom for i'th boundary element. The returned indices are offsets int...
static int WorldRank()
Return the MPI rank in MPI_COMM_WORLD.
int Size() const
Return the logical size of the array.
void VisualizeField(socketstream &sock, const char *vishost, int visport, GridFunction &gf, const char *title, int x, int y, int w, int h, const char *keys, bool vec)
void SetNodalFESpace(FiniteElementSpace *nfes) override
Arbitrary order H1-conforming (continuous) finite elements.
const Element * GetBdrElement(int i) const
Return pointer to the i'th boundary element object.
Class for parallel grid function.
void SetNodalGridFunction(GridFunction *nodes, bool make_owner=false)
Base class representing target-matrix construction algorithms for mesh optimization via the target-ma...
Class for parallel meshes.
const FiniteElement * GetBE(int i) const
Returns pointer to the FiniteElement in the FiniteElementCollection associated with i'th boundary fac...
int VDofToDof(int vdof) const
Compute the inverse of the Dof to VDof mapping for a single index vdof.
A TMOP integrator class based on any given TMOP_QualityMetric and TargetConstructor.