34int main (
int argc,
char *argv[])
40 const char *mesh_file =
"square01.mesh";
42 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.");
60 args.
AddOption(&visport,
"-p",
"--send-port",
"Socket for GLVis.");
70 Mesh *mesh =
new Mesh(mesh_file, 1, 1,
false);
72 ParMesh pmesh(MPI_COMM_WORLD, *mesh);
78 if (mesh_poly_deg <= 0)
98 fit_marker_vis_gf = 0.0;
99 for (
int e = 0; e < pmesh.
GetNBE(); e++)
103 if (attr != 2) {
continue; }
106 for (
int j = 0; j < nd; j++)
108 int j_x = vdofs[j], j_y = vdofs[nd+j];
109 const real_t x = coord(j_x),
110 z = (
dim == 2) ? 0.0 : coord(vdofs[2*nd + j]);
111 fit_marker[pfes_mesh.
VDofToDof(j_x)] =
true;
112 fit_marker_vis_gf(j_x) = 1.0;
113 if (coord(j_y) < 0.5)
115 coord_target(j_y) = 0.1 * sin(4 * M_PI * x) * cos(M_PI * z);
119 if (coord(j_x) < 0.5)
121 coord_target(j_y) = 1.0 + 0.1 * sin(2 * M_PI * x);
125 coord_target(j_y) = 1.0 + 0.1 * sin(2 * M_PI * (x + 0.5));
136 coord = coord_target;
138 "Target positions (DOFS with value 1)",
139 0, 0, 400, 400, (
dim == 2) ?
"Rjm" :
"");
146 for (
int i = 0; i < pmesh.
GetNBE(); i++)
150 MFEM_VERIFY(!(
dim == 2 && attr == 3),
151 "Boundary attribute 3 must be used only for 3D meshes. "
152 "Adjust the attributes (1/2/3/4 for fixed x/y/z/all "
153 "components, rest for free nodes), or use -fix-bnd.");
154 if (attr == 1 || attr == 3) { n += nd; }
155 if (attr == 4) { n += nd *
dim; }
159 for (
int i = 0; i < pmesh.
GetNBE(); i++)
166 for (
int j = 0; j < nd; j++)
167 { ess_vdofs[n++] = vdofs[j]; }
171 for (
int j = 0; j < nd; j++)
172 { ess_vdofs[n++] = vdofs[j+2*nd]; }
176 for (
int j = 0; j < vdofs.
Size(); j++)
177 { ess_vdofs[n++] = vdofs[j]; }
189 integ->EnableSurfaceFitting(coord_target, fit_marker, fit_weight);
199 a.SetEssentialVDofs(ess_vdofs);
200 a.AddDomainIntegrator(integ);
int Size() const
Return the logical size of the array.
A coefficient that is constant across space and time.
int GetAttribute() const
Return element's attribute.
Collection of finite elements from the same family in multiple dimensions. This class is used to matc...
const FiniteElement * GetBE(int i) const
Returns pointer to the FiniteElement in the FiniteElementCollection associated with i'th boundary fac...
int GetNDofs() const
Returns number of degrees of freedom. This is the number of Local Degrees of Freedom.
int VDofToDof(int vdof) const
Compute the inverse of the Dof to VDof mapping for a single index vdof.
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...
int GetDof() const
Returns the number of degrees of freedom in the finite element.
void SetTrueVector()
Shortcut for calling GetTrueDofs() with GetTrueVector() as argument.
void SetFromTrueVector()
Shortcut for calling SetFromTrueDofs() with GetTrueVector() as argument.
const Vector & GetTrueVector() const
Read only access to the (optional) internal true-dof Vector.
Arbitrary order H1-conforming (continuous) finite elements.
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 SetRelTol(real_t rtol)
virtual void SetPrintLevel(int print_lvl)
Legacy method to set the level of verbosity of the solver output.
void SetMaxIter(int max_it)
void SetAbsTol(real_t atol)
void SetOperator(const Operator &op) override
Also calls SetOperator for the preconditioner if there is one.
Geometry::Type GetTypicalElementGeometry() const
If the local mesh is not empty, return GetElementGeometry(0); otherwise, return a typical Geometry pr...
int Dimension() const
Dimension of the reference space used within the elements.
const Element * GetBdrElement(int i) const
Return pointer to the i'th boundary element object.
void SetNodalGridFunction(GridFunction *nodes, bool make_owner=false)
int GetNBE() const
Returns number of boundary elements.
void UniformRefinement(int i, const DSTable &, int *, int *, int *)
static int WorldRank()
Return the MPI rank in MPI_COMM_WORLD.
static void Init(int &argc, char **&argv, int required=default_thread_required, int *provided=nullptr)
Singleton creation with Mpi::Init(argc, argv).
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.
Abstract parallel finite element space.
Class for parallel grid function.
Class for parallel meshes.
void SetNodalFESpace(FiniteElementSpace *nfes) override
Version of QuadraticFECollection with positive basis functions.
void SetAdaptiveSurfaceFittingScalingFactor(real_t factor)
void Mult(const Vector &b, Vector &x) const override
Optimizes the mesh positions given by x.
void SetPreconditioner(Solver &pr) override
This should be called before SetOperator.
void SetTerminationWithMaxSurfaceFittingError(real_t max_error)
Used for error-based surface fitting termination.
A TMOP integrator class based on any given TMOP_QualityMetric and TargetConstructor.
3D barrier Shape (S) metric, well-posed (polyconvex & invex).
Abstract class for local mesh quality metrics in the target-matrix optimization paradigm (TMOP) by P....
Base class representing target-matrix construction algorithms for mesh optimization via the target-ma...
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)
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)
IntegrationRules IntRules(0, Quadrature1D::GaussLegendre)
A global object with all integration rules (defined in intrules.cpp)