46 v(0) = p(0) + s*p(1) + s*p(2);
47 v(1) = p(1) + s*p(2) + s*p(0);
58 for (
int p = 0; p < np; p++)
61 fname << mesh_prefix <<
'.' << setfill(
'0') << setw(6) << p;
62 meshin.open(fname.str().c_str());
65 cerr <<
"Can not open mesh file: " << fname.str().c_str()
67 for (p--; p >= 0; p--)
73 mesh_array[p] =
new Mesh(meshin, 1, 0);
77 for (
int i = 0; i < mesh_array[p]->GetNE(); i++)
79 mesh_array[p]->GetElement(i)->SetAttribute(p+1);
81 for (
int i = 0; i < mesh_array[p]->GetNBE(); i++)
83 mesh_array[p]->GetBdrElement(i)->SetAttribute(p+1);
88 mesh =
new Mesh(mesh_array, np);
90 for (
int p = 0; p < np; p++)
92 delete mesh_array[np-1-p];
99 int main (
int argc,
char *argv[])
102 const char *mesh_file =
"../../data/beam-hex.mesh";
105 args.
AddOption(&mesh_file,
"-m",
"--mesh",
106 "Mesh file to visualize.");
108 "Load mesh from multiple processors.");
117 cout <<
"Visualize and manipulate a serial mesh:\n"
118 <<
" mesh-explorer -m <mesh_file>\n"
119 <<
"Visualize and manipulate a parallel mesh:\n"
120 <<
" mesh-explorer -np <#proc> -m <mesh_prefix>\n" << endl
130 ifstream imesh(mesh_file);
133 cerr <<
"can not open mesh file: " << mesh_file << endl;
136 mesh =
new Mesh(imesh, 1, 1);
167 cout <<
"boundary attribs :";
172 cout <<
'\n' <<
"material attribs :";
178 cout <<
"mesh curvature : ";
185 cout <<
"NONE" << endl;
190 cout <<
"What would you like to do?\n"
193 "c) Change curvature\n"
198 "m) View materials\n"
201 "h) View element sizes, h\n"
202 "k) View element ratios, kappa\n"
203 "x) Print sub-element stats\n"
204 "p) Generate a partitioning\n"
224 cout <<
"enter new order for mesh curvature --> " << flush;
233 cout <<
"scaling factor ---> " << flush;
239 for (
int i = 0; i < mesh->
GetNV(); i++)
267 cout <<
"jitter factor ---> " << flush;
274 cerr <<
"The mesh should have nodes, introduce curvature first!\n";
287 h0 = std::numeric_limits<double>::infinity();
290 for (
int i = 0; i < fespace->
GetNE(); i++)
293 for (
int j = 0; j < dofs.
Size(); j++)
301 for (
int i = 0; i < fespace->
GetNDofs(); i++)
303 for (
int d = 0; d <
dim; d++)
314 for (
int i = 0; i < fespace->
GetNBE(); i++)
317 for (
int j = 0; j < vdofs.
Size(); j++)
334 double min_det_J, max_det_J, min_det_J_z, max_det_J_z;
335 double min_kappa, max_kappa, max_ratio_det_J_z;
336 min_det_J = min_kappa = numeric_limits<double>::infinity();
337 max_det_J = max_kappa = max_ratio_det_J_z = -min_det_J;
338 cout <<
"subdivision factor ---> " << flush;
340 for (
int i = 0; i < mesh->
GetNE(); i++)
348 min_det_J_z = numeric_limits<double>::infinity();
349 max_det_J_z = -min_det_J_z;
355 double det_J = J.
Det();
359 min_det_J_z = fmin(min_det_J_z, det_J);
360 max_det_J_z = fmax(max_det_J_z, det_J);
362 min_kappa = fmin(min_kappa, kappa);
363 max_kappa = fmax(max_kappa, kappa);
366 fmax(max_ratio_det_J_z, max_det_J_z/min_det_J_z);
367 min_det_J = fmin(min_det_J, min_det_J_z);
368 max_det_J = fmax(max_det_J, max_det_J_z);
369 if (min_det_J_z <= 0.0)
375 <<
"\nbad elements = " << nz
376 <<
"\nmin det(J) = " << min_det_J
377 <<
"\nmax det(J) = " << max_det_J
378 <<
"\nglobal ratio = " << max_det_J/min_det_J
379 <<
"\nmax el ratio = " << max_ratio_det_J_z
380 <<
"\nmin kappa = " << min_kappa
381 <<
"\nmax kappa = " << max_kappa << endl;
384 if (mk ==
'm' || mk ==
'b' || mk ==
'e' || mk ==
'v' || mk ==
'h' ||
385 mk ==
'k' || mk ==
'p')
393 for (
int i = 0; i < mesh->
GetNE(); i++)
398 if (mk ==
'b' || mk ==
'v')
407 double a = double(random()) / (double(RAND_MAX) + 1.);
408 int el0 = (int)floor(a * mesh->
GetNE());
409 cout <<
"Generating coloring starting with element " << el0+1
410 <<
" / " << mesh->
GetNE() << endl;
412 for (
int i = 0; i < coloring.
Size(); i++)
414 attr(i) = coloring[i];
416 cout <<
"Number of colors: " << attr.
Max() + 1 << endl;
417 for (
int i = 0; i < mesh->
GetNE(); i++)
420 attr(i) = part[i] = i;
428 h_min = numeric_limits<double>::infinity();
430 for (
int i = 0; i < mesh->
GetNE(); i++)
440 attr(i) = -pow(-attr(i), 1.0/
double(dim));
444 attr(i) = pow(attr(i), 1.0/
double(dim));
446 h_min = min(h_min, attr(i));
447 h_max = max(h_max, attr(i));
449 cout <<
"h_min = " << h_min <<
", h_max = " << h_max << endl;
455 for (
int i = 0; i < mesh->
GetNE(); i++)
467 int *partitioning = NULL, n;
468 cout <<
"What type of partitioning?\n"
470 "0) METIS_PartGraphRecursive (sorted neighbor lists)\n"
471 "1) METIS_PartGraphKway (sorted neighbor lists)\n"
472 "2) METIS_PartGraphVKway (sorted neighbor lists)\n"
473 "3) METIS_PartGraphRecursive\n"
474 "4) METIS_PartGraphKway\n"
475 "5) METIS_PartGraphVKway\n"
482 cout <<
"Enter nx: " << flush;
483 cin >> nxyz[0]; n = nxyz[0];
486 cout <<
"Enter ny: " << flush;
487 cin >> nxyz[1]; n *= nxyz[1];
490 cout <<
"Enter nz: " << flush;
491 cin >> nxyz[2]; n *= nxyz[2];
498 int part_method = pk -
'0';
499 if (part_method < 0 || part_method > 5)
503 cout <<
"Enter number of processors: " << flush;
509 const char part_file[] =
"partitioning.txt";
510 ofstream opart(part_file);
511 opart <<
"number_of_elements " << mesh->
GetNE() <<
'\n'
512 <<
"number_of_processors " << n <<
'\n';
513 for (
int i = 0; i < mesh->
GetNE(); i++)
515 opart << partitioning[i] <<
'\n';
517 cout <<
"Partitioning file: " << part_file << endl;
521 for (
int i = 0; i < mesh->
GetNE(); i++)
523 proc_el[partitioning[i]]++;
525 int min_el = proc_el[0], max_el = proc_el[0];
526 for (
int i = 1; i < n; i++)
528 if (min_el > proc_el[i])
532 if (max_el < proc_el[i])
537 cout <<
"Partitioning stats:\n"
539 << setw(12) <<
"minimum"
540 << setw(12) <<
"average"
541 << setw(12) <<
"maximum"
542 << setw(12) <<
"total" <<
'\n';
544 << setw(12) << min_el
545 << setw(12) << double(mesh->
GetNE())/n
546 << setw(12) << max_el
547 << setw(12) << mesh->
GetNE() << endl;
554 for (
int i = 0; i < mesh->
GetNE(); i++)
556 attr(i) = part[i] = partitioning[i];
558 delete [] partitioning;
561 char vishost[] =
"localhost";
566 sol_sock.precision(14);
569 sol_sock <<
"fem2d_gf_data_keys\n";
572 mesh->
Print(sol_sock);
579 mesh->
Print(sol_sock);
580 for (
int i = 0; i < mesh->
GetNE(); i++)
591 sol_sock <<
"RjlmAb***********";
603 sol_sock <<
"fem3d_gf_data_keys\n";
604 if (mk ==
'b' || mk ==
'v' || mk ==
'h' || mk ==
'k')
606 mesh->
Print(sol_sock);
613 mesh->
Print(sol_sock);
614 for (
int i = 0; i < mesh->
GetNE(); i++)
638 cout <<
"Unable to connect to "
639 << vishost <<
':' << visport << endl;
645 const char mesh_file[] =
"mesh-explorer.mesh";
646 ofstream omesh(mesh_file);
649 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.
int * CartesianPartitioning(int nxyz[])
int GetNDofs() const
Returns number of degrees of freedom.
Class for integration rule.
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
double Det() const
Calculates the determinant of the matrix (for 2x2 or 3x3 matrices)
int GetElementBaseGeometry(int i) const
RefinedGeometry * Refine(int Geom, int Times, int ETimes=1)
Data type dense matrix using column-major storage.
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)
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
virtual void Print(std::ostream &out=std::cout) const
Print the mesh to the given stream using the default MFEM mesh format.
Array< int > bdr_attributes
int main(int argc, char *argv[])
Abstract finite element space.
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)
void PrintCharacteristics(Vector *Vh=NULL, Vector *Vk=NULL, std::ostream &out=std::cout)
void SetSize(int nsize)
Change logical size of the array, keep existing entries.
NURBSExtension * NURBSext
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()
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.
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.