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 mesh =
new Mesh(mesh_file, 1, 1);
160 cout <<
"boundary attribs :";
165 cout <<
'\n' <<
"material attribs :";
171 cout <<
"mesh curvature : ";
178 cout <<
"NONE" << endl;
183 cout <<
"What would you like to do?\n"
186 "c) Change curvature\n"
191 "m) View materials\n"
194 "h) View element sizes, h\n"
195 "k) View element ratios, kappa\n"
196 "x) Print sub-element stats\n"
197 "p) Generate a partitioning\n"
217 cout <<
"enter new order for mesh curvature --> " << flush;
226 cout <<
"scaling factor ---> " << flush;
232 for (
int i = 0; i < mesh->
GetNV(); i++)
260 cout <<
"jitter factor ---> " << flush;
267 cerr <<
"The mesh should have nodes, introduce curvature first!\n";
280 h0 = std::numeric_limits<double>::infinity();
283 for (
int i = 0; i < fespace->
GetNE(); i++)
286 for (
int j = 0; j < dofs.
Size(); j++)
294 for (
int i = 0; i < fespace->
GetNDofs(); i++)
296 for (
int d = 0; d <
dim; d++)
307 for (
int i = 0; i < fespace->
GetNBE(); i++)
310 for (
int j = 0; j < vdofs.
Size(); j++)
327 double min_det_J, max_det_J, min_det_J_z, max_det_J_z;
328 double min_kappa, max_kappa, max_ratio_det_J_z;
329 min_det_J = min_kappa = numeric_limits<double>::infinity();
330 max_det_J = max_kappa = max_ratio_det_J_z = -min_det_J;
331 cout <<
"subdivision factor ---> " << flush;
333 for (
int i = 0; i < mesh->
GetNE(); i++)
341 min_det_J_z = numeric_limits<double>::infinity();
342 max_det_J_z = -min_det_J_z;
348 double det_J = J.
Det();
352 min_det_J_z = fmin(min_det_J_z, det_J);
353 max_det_J_z = fmax(max_det_J_z, det_J);
355 min_kappa = fmin(min_kappa, kappa);
356 max_kappa = fmax(max_kappa, kappa);
359 fmax(max_ratio_det_J_z, max_det_J_z/min_det_J_z);
360 min_det_J = fmin(min_det_J, min_det_J_z);
361 max_det_J = fmax(max_det_J, max_det_J_z);
362 if (min_det_J_z <= 0.0)
368 <<
"\nbad elements = " << nz
369 <<
"\nmin det(J) = " << min_det_J
370 <<
"\nmax det(J) = " << max_det_J
371 <<
"\nglobal ratio = " << max_det_J/min_det_J
372 <<
"\nmax el ratio = " << max_ratio_det_J_z
373 <<
"\nmin kappa = " << min_kappa
374 <<
"\nmax kappa = " << max_kappa << endl;
377 if (mk ==
'm' || mk ==
'b' || mk ==
'e' || mk ==
'v' || mk ==
'h' ||
378 mk ==
'k' || mk ==
'p')
386 for (
int i = 0; i < mesh->
GetNE(); i++)
391 if (mk ==
'b' || mk ==
'v')
400 double a = double(random()) / (double(RAND_MAX) + 1.);
401 int el0 = (int)floor(a * mesh->
GetNE());
402 cout <<
"Generating coloring starting with element " << el0+1
403 <<
" / " << mesh->
GetNE() << endl;
405 for (
int i = 0; i < coloring.
Size(); i++)
407 attr(i) = coloring[i];
409 cout <<
"Number of colors: " << attr.
Max() + 1 << endl;
410 for (
int i = 0; i < mesh->
GetNE(); i++)
413 attr(i) = part[i] = i;
421 h_min = numeric_limits<double>::infinity();
423 for (
int i = 0; i < mesh->
GetNE(); i++)
433 attr(i) = -pow(-attr(i), 1.0/
double(dim));
437 attr(i) = pow(attr(i), 1.0/
double(dim));
439 h_min = min(h_min, attr(i));
440 h_max = max(h_max, attr(i));
442 cout <<
"h_min = " << h_min <<
", h_max = " << h_max << endl;
448 for (
int i = 0; i < mesh->
GetNE(); i++)
460 int *partitioning = NULL, n;
461 cout <<
"What type of partitioning?\n"
463 "0) METIS_PartGraphRecursive (sorted neighbor lists)\n"
464 "1) METIS_PartGraphKway (sorted neighbor lists)\n"
465 "2) METIS_PartGraphVKway (sorted neighbor lists)\n"
466 "3) METIS_PartGraphRecursive\n"
467 "4) METIS_PartGraphKway\n"
468 "5) METIS_PartGraphVKway\n"
475 cout <<
"Enter nx: " << flush;
476 cin >> nxyz[0]; n = nxyz[0];
479 cout <<
"Enter ny: " << flush;
480 cin >> nxyz[1]; n *= nxyz[1];
483 cout <<
"Enter nz: " << flush;
484 cin >> nxyz[2]; n *= nxyz[2];
491 int part_method = pk -
'0';
492 if (part_method < 0 || part_method > 5)
496 cout <<
"Enter number of processors: " << flush;
502 const char part_file[] =
"partitioning.txt";
503 ofstream opart(part_file);
504 opart <<
"number_of_elements " << mesh->
GetNE() <<
'\n'
505 <<
"number_of_processors " << n <<
'\n';
506 for (
int i = 0; i < mesh->
GetNE(); i++)
508 opart << partitioning[i] <<
'\n';
510 cout <<
"Partitioning file: " << part_file << endl;
514 for (
int i = 0; i < mesh->
GetNE(); i++)
516 proc_el[partitioning[i]]++;
518 int min_el = proc_el[0], max_el = proc_el[0];
519 for (
int i = 1; i < n; i++)
521 if (min_el > proc_el[i])
525 if (max_el < proc_el[i])
530 cout <<
"Partitioning stats:\n"
532 << setw(12) <<
"minimum"
533 << setw(12) <<
"average"
534 << setw(12) <<
"maximum"
535 << setw(12) <<
"total" <<
'\n';
537 << setw(12) << min_el
538 << setw(12) << double(mesh->
GetNE())/n
539 << setw(12) << max_el
540 << setw(12) << mesh->
GetNE() << endl;
547 for (
int i = 0; i < mesh->
GetNE(); i++)
549 attr(i) = part[i] = partitioning[i];
551 delete [] partitioning;
554 char vishost[] =
"localhost";
559 sol_sock.precision(14);
562 sol_sock <<
"fem2d_gf_data_keys\n";
565 mesh->
Print(sol_sock);
572 mesh->
Print(sol_sock);
573 for (
int i = 0; i < mesh->
GetNE(); i++)
584 sol_sock <<
"RjlmAb***********";
596 sol_sock <<
"fem3d_gf_data_keys\n";
597 if (mk ==
'b' || mk ==
'v' || mk ==
'h' || mk ==
'k')
599 mesh->
Print(sol_sock);
606 mesh->
Print(sol_sock);
607 for (
int i = 0; i < mesh->
GetNE(); i++)
631 cout <<
"Unable to connect to "
632 << vishost <<
':' << visport << endl;
638 const char mesh_file[] =
"mesh-explorer.mesh";
639 ofstream omesh(mesh_file);
642 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)
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)
int main(int argc, char *argv[])
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
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.
int GetElementBaseGeometry(int i=0) const
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() 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.
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.