35int 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 real_t 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);
198 a.SetEssentialVDofs(ess_vdofs);
199 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...
Geometry::Type GetGeomType() const
Returns the Geometry::Type of the reference element.
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)
virtual void SetOperator(const Operator &op)
Also calls SetOperator for the preconditioner if there is one.
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.
const FiniteElement * GetFE(int i) const override
Class for parallel grid function.
Class for parallel meshes.
void SetNodalFESpace(FiniteElementSpace *nfes) override
Version of QuadraticFECollection with positive basis functions.
void EnableAdaptiveSurfaceFitting()
virtual void Mult(const Vector &b, Vector &x) const
Solve the nonlinear system with right-hand side b.
void SetTerminationWithMaxSurfaceFittingError(real_t max_error)
virtual void SetPreconditioner(Solver &pr)
This should be called before SetOperator.
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)