49 v(0) = p(0) + s*p(1) + s*p(2);
50 v(1) = p(1) + s*p(2) + s*p(0);
53 else if (p.
Size() == 2)
70 for (
int p = 0; p < np; p++)
73 fname << mesh_prefix <<
'.' << setfill(
'0') << setw(6) << p;
77 cerr <<
"Can not open mesh file: " << fname.str().c_str()
79 for (p--; p >= 0; p--)
85 mesh_array[p] =
new Mesh(meshin, 1, 0);
89 for (
int i = 0; i < mesh_array[p]->GetNE(); i++)
91 mesh_array[p]->GetElement(i)->SetAttribute(p+1);
93 for (
int i = 0; i < mesh_array[p]->GetNBE(); i++)
95 mesh_array[p]->GetBdrElement(i)->SetAttribute(p+1);
99 mesh =
new Mesh(mesh_array, np);
101 for (
int p = 0; p < np; p++)
103 delete mesh_array[np-1-p];
110 int main (
int argc,
char *argv[])
113 const char *mesh_file =
"../../data/beam-hex.mesh";
116 args.
AddOption(&mesh_file,
"-m",
"--mesh",
117 "Mesh file to visualize.");
119 "Load mesh from multiple processors.");
128 cout <<
"Visualize and manipulate a serial mesh:\n"
129 <<
" mesh-explorer -m <mesh_file>\n"
130 <<
"Visualize and manipulate a parallel mesh:\n"
131 <<
" mesh-explorer -np <#proc> -m <mesh_prefix>\n" << endl
141 mesh =
new Mesh(mesh_file, 1, 1);
171 cout <<
"boundary attribs :";
176 cout <<
'\n' <<
"material attribs :";
182 cout <<
"mesh curvature : ";
189 cout <<
"NONE" << endl;
194 cout <<
"What would you like to do?\n"
197 "c) Change curvature\n"
202 "m) View materials\n"
205 "h) View element sizes, h\n"
206 "k) View element ratios, kappa\n"
207 "x) Print sub-element stats\n"
208 "f) Find physical point in reference space\n"
209 "p) Generate a partitioning\n"
223 "Choose type of refinement:\n"
224 "s) standard refinement with Mesh::UniformRefinement()\n"
225 "u) uniform refinement with a factor\n"
226 "g) non-uniform refinement (Gauss-Lobatto) with a factor\n"
238 cout <<
"enter refinement factor --> " << flush;
241 if (ref_factor <= 1 || ref_factor > 32) {
break; }
244 Mesh *rmesh =
new Mesh(mesh, ref_factor, ref_type);
256 cout <<
"enter new order for mesh curvature --> " << flush;
265 cout <<
"scaling factor ---> " << flush;
271 for (
int i = 0; i < mesh->
GetNV(); i++)
299 cout <<
"jitter factor ---> " << flush;
306 cerr <<
"The mesh should have nodes, introduce curvature first!\n";
319 h0 = std::numeric_limits<double>::infinity();
322 for (
int i = 0; i < fespace->
GetNE(); i++)
325 for (
int j = 0; j < dofs.
Size(); j++)
333 for (
int i = 0; i < fespace->
GetNDofs(); i++)
335 for (
int d = 0; d <
dim; d++)
346 for (
int i = 0; i < fespace->
GetNBE(); i++)
349 for (
int j = 0; j < vdofs.
Size(); j++)
366 double min_det_J, max_det_J, min_det_J_z, max_det_J_z;
367 double min_kappa, max_kappa, max_ratio_det_J_z;
368 min_det_J = min_kappa = numeric_limits<double>::infinity();
369 max_det_J = max_kappa = max_ratio_det_J_z = -min_det_J;
370 cout <<
"subdivision factor ---> " << flush;
372 for (
int i = 0; i < mesh->
GetNE(); i++)
380 min_det_J_z = numeric_limits<double>::infinity();
381 max_det_J_z = -min_det_J_z;
387 double det_J = J.
Det();
391 min_det_J_z = fmin(min_det_J_z, det_J);
392 max_det_J_z = fmax(max_det_J_z, det_J);
394 min_kappa = fmin(min_kappa, kappa);
395 max_kappa = fmax(max_kappa, kappa);
398 fmax(max_ratio_det_J_z, max_det_J_z/min_det_J_z);
399 min_det_J = fmin(min_det_J, min_det_J_z);
400 max_det_J = fmax(max_det_J, max_det_J_z);
401 if (min_det_J_z <= 0.0)
406 cout <<
"\nbad elements = " << nz
407 <<
"\nmin det(J) = " << min_det_J
408 <<
"\nmax det(J) = " << max_det_J
409 <<
"\nglobal ratio = " << max_det_J/min_det_J
410 <<
"\nmax el ratio = " << max_ratio_det_J_z
411 <<
"\nmin kappa = " << min_kappa
412 <<
"\nmax kappa = " << max_kappa << endl;
418 cout <<
"\npoint in physical space ---> " << flush;
419 for (
int i = 0; i < sdim; i++)
421 cin >> point_mat(i,0);
429 cout <<
"point in reference space:";
430 if (elem_ids[0] == -1)
432 cout <<
" NOT FOUND!\n";
436 cout <<
" element " << elem_ids[0] <<
", ip =";
437 cout <<
" " << ips[0].x;
440 cout <<
" " << ips[0].y;
443 cout <<
" " << ips[0].z;
450 if (mk ==
'm' || mk ==
'b' || mk ==
'e' || mk ==
'v' || mk ==
'h' ||
451 mk ==
'k' || mk ==
'p')
459 for (
int i = 0; i < mesh->
GetNE(); i++)
464 if (mk ==
'b' || mk ==
'v')
473 double a = double(rand()) / (double(RAND_MAX) + 1.);
474 int el0 = (int)floor(a * mesh->
GetNE());
475 cout <<
"Generating coloring starting with element " << el0+1
476 <<
" / " << mesh->
GetNE() << endl;
478 for (
int i = 0; i < coloring.
Size(); i++)
480 attr(i) = coloring[i];
482 cout <<
"Number of colors: " << attr.
Max() + 1 << endl;
483 for (
int i = 0; i < mesh->
GetNE(); i++)
486 attr(i) = part[i] = i;
494 h_min = numeric_limits<double>::infinity();
496 for (
int i = 0; i < mesh->
GetNE(); i++)
506 attr(i) = -pow(-attr(i), 1.0/
double(dim));
510 attr(i) = pow(attr(i), 1.0/
double(dim));
512 h_min = min(h_min, attr(i));
513 h_max = max(h_max, attr(i));
515 cout <<
"h_min = " << h_min <<
", h_max = " << h_max << endl;
521 for (
int i = 0; i < mesh->
GetNE(); i++)
533 int *partitioning = NULL, n;
534 cout <<
"What type of partitioning?\n"
536 "0) METIS_PartGraphRecursive (sorted neighbor lists)\n"
537 "1) METIS_PartGraphKway (sorted neighbor lists)\n"
538 "2) METIS_PartGraphVKway (sorted neighbor lists)\n"
539 "3) METIS_PartGraphRecursive\n"
540 "4) METIS_PartGraphKway\n"
541 "5) METIS_PartGraphVKway\n"
548 cout <<
"Enter nx: " << flush;
549 cin >> nxyz[0]; n = nxyz[0];
552 cout <<
"Enter ny: " << flush;
553 cin >> nxyz[1]; n *= nxyz[1];
556 cout <<
"Enter nz: " << flush;
557 cin >> nxyz[2]; n *= nxyz[2];
564 int part_method = pk -
'0';
565 if (part_method < 0 || part_method > 5)
569 cout <<
"Enter number of processors: " << flush;
575 const char part_file[] =
"partitioning.txt";
576 ofstream opart(part_file);
577 opart <<
"number_of_elements " << mesh->
GetNE() <<
'\n'
578 <<
"number_of_processors " << n <<
'\n';
579 for (
int i = 0; i < mesh->
GetNE(); i++)
581 opart << partitioning[i] <<
'\n';
583 cout <<
"Partitioning file: " << part_file << endl;
587 for (
int i = 0; i < mesh->
GetNE(); i++)
589 proc_el[partitioning[i]]++;
591 int min_el = proc_el[0], max_el = proc_el[0];
592 for (
int i = 1; i < n; i++)
594 if (min_el > proc_el[i])
598 if (max_el < proc_el[i])
603 cout <<
"Partitioning stats:\n"
605 << setw(12) <<
"minimum"
606 << setw(12) <<
"average"
607 << setw(12) <<
"maximum"
608 << setw(12) <<
"total" <<
'\n';
610 << setw(12) << min_el
611 << setw(12) << double(mesh->
GetNE())/n
612 << setw(12) << max_el
613 << setw(12) << mesh->
GetNE() << endl;
620 for (
int i = 0; i < mesh->
GetNE(); i++)
622 attr(i) = part[i] = partitioning[i];
624 delete [] partitioning;
627 char vishost[] =
"localhost";
632 sol_sock.precision(14);
635 sol_sock <<
"fem2d_gf_data_keys\n";
638 mesh->
Print(sol_sock);
645 mesh->
Print(sol_sock);
646 for (
int i = 0; i < mesh->
GetNE(); i++)
657 sol_sock <<
"RjlmAb***********";
669 sol_sock <<
"fem3d_gf_data_keys\n";
670 if (mk ==
'b' || mk ==
'v' || mk ==
'h' || mk ==
'k')
672 mesh->
Print(sol_sock);
679 mesh->
Print(sol_sock);
680 for (
int i = 0; i < mesh->
GetNE(); i++)
705 cout <<
"Unable to connect to "
706 << vishost <<
':' << visport << endl;
713 const char mesh_file[] =
"mesh-explorer.mesh";
714 ofstream omesh(mesh_file);
719 cout <<
"New mesh file: " << mesh_file << endl;
int GetNPoints() const
Returns the number of the points in the integration rule.
int Size() const
Logical size of the array.
virtual void Print(std::ostream &out=mfem::out) const
int * CartesianPartitioning(int nxyz[])
int GetNDofs() const
Returns number of degrees of freedom.
Class for an integration rule - an Array of IntegrationPoint.
const double * GetVertex(int i) const
Return pointer to vertex i's coordinates.
Class for grid function - Vector with associated FE space.
int DofToVDof(int dof, int vd, int ndofs=-1) const
Mesh * read_par_mesh(int np, const char *mesh_prefix)
void JacToPerfJac(int GeomType, const DenseMatrix &J, DenseMatrix &PJ) const
int * GeneratePartitioning(int nparts, int part_method=1)
void PrintWithPartitioning(int *partitioning, std::ostream &out, int elem_attr=0) const
RefinedGeometry * Refine(int Geom, int Times, int ETimes=1)
Data type dense matrix using column-major storage.
int Size() const
Returns the size of the vector.
void Transform(void(*f)(const Vector &, Vector &))
int GetNE() const
Returns number of elements.
void PrintHelp(std::ostream &out) const
void Randomize(int seed=0)
Set random values in the vector.
const IntegrationPoint & GetCenter(int GeomType)
Return the center of the given Geometry::Type, GeomType.
void DeleteAll()
Delete whole array.
virtual void Save(std::ostream &out) const
Save the GridFunction to an output stream.
int GetNE() const
Returns number of elements in the mesh.
IntegrationPoint & IntPoint(int i)
Returns a reference to the i-th integration point.
int GetNBE() const
Returns number of boundary elements in the mesh.
void transformation(const Vector &p, Vector &v)
void UniformRefinement(int i, const DSTable &, int *, int *, int *)
void SetCurvature(int order, bool discont=false, int space_dim=-1, int ordering=1)
virtual void GetElementDofs(int i, Array< int > &dofs) const
Returns indexes of degrees of freedom in array dofs for i'th element.
GeometryRefiner GlobGeometryRefiner
FiniteElementSpace * FESpace()
double GetElementSize(int i, int type=0)
int SpaceDimension() const
Array< int > bdr_attributes
A list of all unique boundary attributes used by the Mesh.
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)
Nodes: x_i = i/(n-1), i=0,...,n-1.
void SetSize(int nsize)
Change logical size of the array, keep existing entries.
int GetElementBaseGeometry(int i=0) const
NURBSExtension * NURBSext
Optional NURBS mesh extension.
int GetNV() const
Returns number of vertices. Vertices are only at the corners of elements, where you would expect them...
void PrintError(std::ostream &out) const
virtual const char * Name() const
void GetElementTransformation(int i, IsoparametricTransformation *ElTr)
double Max() const
Returns the maximal element of the vector.
const FiniteElementSpace * GetNodalFESpace() const
void PrintOptions(std::ostream &out) const
double CalcSingularvalue(const int i) const
Return the i-th singular value (decreasing order) of NxN matrix, N=1,2,3.
virtual int FindPoints(DenseMatrix &point_mat, Array< int > &elem_ids, Array< IntegrationPoint > &ips, bool warn=true, InverseElementTransformation *inv_trans=NULL)
Find the ids of the elements that contain the given points, and their corresponding reference coordin...
const FiniteElementCollection * FEColl() const
void GetNodes(Vector &node_coord) const
void GetElementColoring(Array< int > &colors, int el0=0)
void GetBdrElementVDofs(int i, Array< int > &vdofs) const
Returns indexes of degrees of freedom for i'th boundary element.
int GetAttribute(int i) const
Return the attribute of element i.
Array< int > attributes
A list of all unique element attributes used by the Mesh.
void PrintCharacteristics(Vector *Vh=NULL, Vector *Vk=NULL, std::ostream &out=mfem::out)