54 int main(
int argc,
char *argv[])
57 const char *mesh_file =
"../../data/beam-tet.vtk";
60 bool visualization = 1;
63 args.
AddOption(&mesh_file,
"-m",
"--mesh",
66 "Set of attributes to remove from the mesh.");
67 args.
AddOption(&bdr_attr,
"-b",
"--bdr-attr",
68 "Set of attributes to assign to the new boundary elements.");
69 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
71 "Enable or disable GLVis visualization.");
80 Mesh mesh(mesh_file, 0, 0);
85 if (bdr_attr.
Size() == 0)
88 for (
int i=0; i<attr.
Size(); i++)
90 bdr_attr[i] = max_bdr_attr + attr[i];
93 MFEM_VERIFY(attr.
Size() == bdr_attr.
Size(),
94 "Size mismatch in attribute arguments.");
100 for (
int i=0; i<attr.
Size(); i++)
102 marker[attr[i]-1] = 1;
103 attr_inv[attr[i]-1] = i;
107 int num_elements = 0;
108 for (
int e=0; e<mesh.
GetNE(); e++)
111 if (!marker[elem_attr-1]) { num_elements++; }
115 int num_bdr_elements = 0;
118 int e1 = -1, e2 = -1;
125 if (a1 == 0 || a2 == 0)
127 if (a1 == 0 && !marker[a2-1]) { num_bdr_elements++; }
128 else if (a2 == 0 && !marker[a1-1]) { num_bdr_elements++; }
132 if (marker[a1-1] && !marker[a2-1]) { num_bdr_elements++; }
133 else if (!marker[a1-1] && marker[a2-1]) { num_bdr_elements++; }
137 cout <<
"Number of Elements: " << mesh.
GetNE() <<
" -> " 138 << num_elements << endl;
139 cout <<
"Number of Boundary Elements: " << mesh.
GetNBE() <<
" -> " 140 << num_bdr_elements << endl;
146 for (
int v=0; v<mesh.
GetNV(); v++)
152 for (
int e=0; e<mesh.
GetNE(); e++)
156 if (!marker[elem_attr-1])
161 trimmed_mesh.AddElement(nel);
166 for (
int be=0; be<mesh.
GetNBE(); be++)
172 if (!marker[elem_attr-1])
175 trimmed_mesh.AddBdrElement(nbel);
182 int e1 = -1, e2 = -1;
185 int i1 = -1, i2 = -1;
192 if (a1 != 0 && a2 != 0)
194 if (marker[a1-1] && !marker[a2-1])
200 trimmed_mesh.AddBdrElement(bel);
202 else if (!marker[a1-1] && marker[a2-1])
208 trimmed_mesh.AddBdrElement(bel);
213 trimmed_mesh.FinalizeTopology();
214 trimmed_mesh.Finalize();
215 trimmed_mesh.RemoveUnusedVertices();
231 trimmed_mesh.SetCurvature(order, discont, sdim, ordering);
242 for (
int e = 0; e < mesh.
GetNE(); e++)
246 if (!marker[elem_attr-1])
259 ofstream mesh_ofs(
"trimmer.mesh");
260 mesh_ofs.precision(8);
261 trimmed_mesh.Print(mesh_ofs);
269 sol_sock.precision(8);
270 sol_sock <<
"mesh\n" << trimmed_mesh << flush;
void SetSubVector(const Array< int > &dofs, const double value)
Set the entries listed in dofs to the given value.
Class for grid function - Vector with associated FE space.
virtual Element * Duplicate(Mesh *m) const =0
virtual void GetVertices(Array< int > &v) const =0
Returns element's vertices.
void PrintOptions(std::ostream &out) const
Print the options.
int Dimension() const
Dimension of the reference space used within the elements.
int GetNumFaces() const
Return the number of faces (3D), edges (2D) or vertices (1D).
void PrintUsage(std::ostream &out) const
Print the usage message.
int GetOrder() const
Return the order (polynomial degree) of the FE collection, corresponding to the order/degree returned...
int GetAttribute() const
Return element's attribute.
T Max() const
Find the maximal element in the array, using the comparison operator < for class T.
virtual void SetVertices(const int *ind)
Set the indices the element according to the input.
const Element * GetElement(int i) const
Return pointer to the i'th element object.
bool Good() const
Return true if the command line options were parsed successfully.
void GetSubVector(const Array< int > &dofs, Vector &elemvect) const
Extract entries listed in dofs to the output Vector elemvect.
int GetNBE() const
Returns number of boundary elements.
Element * NewElement(int geom)
void GetFaceElements(int Face, int *Elem1, int *Elem2) const
int GetNV() const
Returns number of vertices. Vertices are only at the corners of elements, where you would expect them...
int AddVertex(double x, double y=0.0, double z=0.0)
Geometry::Type GetGeometryType() const
void Parse()
Parse the command-line options. Note that this function expects all the options provided through the ...
const FiniteElementCollection * FEColl() const
const double * GetVertex(int i) const
Return pointer to vertex i's coordinates.
void GetFaceInfos(int Face, int *Inf1, int *Inf2) const
FiniteElementSpace * FESpace()
DofTransformation * GetElementVDofs(int i, Array< int > &vdofs) const
Returns indices of degrees of freedom for the i'th element. The returned indices are offsets into an ...
Array< int > bdr_attributes
A list of all unique boundary attributes used by the Mesh.
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...
void SetSize(int nsize)
Change the logical size of the array, keep existing entries.
int main(int argc, char *argv[])
int SpaceDimension() const
Dimension of the physical space containing the mesh.
int GetNE() const
Returns number of elements.
Ordering::Type GetOrdering() const
Return the ordering method.
const Element * GetFace(int i) const
void SetAttribute(const int attr)
Set element's attribute.
int Size() const
Return the logical size of the array.
void GetNodes(Vector &node_coord) const
const Element * GetBdrElement(int i) const
Return pointer to the i'th boundary element object.
Abstract data type element.
Array< int > attributes
A list of all unique element attributes used by the Mesh.
void GetBdrElementAdjacentElement(int bdr_el, int &el, int &info) const
For the given boundary element, bdr_el, return its adjacent element and its info, i...
Arbitrary order "L2-conforming" discontinuous finite elements.
double f(const Vector &p)