14 mesh::mesh(Epetra_Comm & comm, std::string & fileName_mesh,
double scaling){
16 int MyPID =
Comm->MyPID();
17 int NumProc =
Comm->NumProc();
25 if (
Comm->NumProc()>1){
34 for (
unsigned int n=0; n<
n_nodes; ++n){
66 std::ifstream meshfile;
67 meshfile.open(fileName_mesh.c_str());
70 std::cout <<
"*ERR* Can't open the input file\n ";
77 unsigned int n_total_cells;
83 unsigned int n_faces3 = 0;
84 unsigned int n_quad4 = 0;
85 unsigned int n_faces6 = 0;
86 unsigned int n_cells4 = 0;
87 unsigned int n_hexa8 = 0;
88 unsigned int n_cells10 = 0;
90 unsigned int nodes_faces3[3];
91 unsigned int nodes_quad4[4];
92 unsigned int nodes_faces6[6];
93 unsigned int nodes_cells4[4];
94 unsigned int nodes_hexa8[8];
95 unsigned int nodes_cells10[10];
97 std::vector<int> tri3_nodes;
98 std::vector<int> quad4_nodes;
99 std::vector<int> tri6_nodes;
100 std::vector<int> tetra4_nodes;
101 std::vector<int> hexa8_nodes;
102 std::vector<int> tetra10_nodes;
104 meshfile.getline(buf,100);
105 meshfile.getline(buf,100);
106 meshfile.getline(buf,100);
107 meshfile.getline(buf,100);
123 meshfile.getline(buf,100);
124 meshfile.getline(buf,100);
125 meshfile.getline(buf,100);
126 meshfile >> n_total_cells;
127 meshfile.getline(buf,100);
129 for (
int i=0;
i<n_total_cells; ++
i){
138 for (
unsigned int inode=0; inode<2; ++inode){
143 for (
unsigned int inode=0; inode<3; ++inode){
144 meshfile >> nodes_faces3[inode];
145 tri3_nodes.push_back(nodes_faces3[inode]-1);
149 for (
unsigned int inode=0; inode<4; ++inode){
150 meshfile >> nodes_quad4[inode];
151 if (tag1==92 || tag1==93){
152 quad4_nodes.push_back(nodes_quad4[inode]-1);
157 for (
unsigned int inode=0; inode<4; ++inode){
158 meshfile >> nodes_cells4[inode];
159 tetra4_nodes.push_back(nodes_cells4[inode]-1);
163 for (
unsigned int inode=0; inode<8; ++inode){
164 meshfile >> nodes_hexa8[inode];
165 hexa8_nodes.push_back(nodes_hexa8[inode]-1);
169 for (
unsigned int inode=0; inode<6; ++inode){
170 meshfile >> nodes_faces6[inode];
172 tri6_nodes.push_back(nodes_faces6[inode]-1);
177 for (
unsigned int inode=0; inode<10; ++inode){
178 meshfile >> nodes_cells10[inode];
179 tetra10_nodes.push_back(nodes_cells10[inode]-1);
183 for (
unsigned int inode=0; inode<1; ++inode){
188 std::cout <<
"Element not supported encountered: el_info = " << el_info <<
"\n";
194 n_faces3 = tri3_nodes.size()/3;
195 n_quad4 = quad4_nodes.size()/4;
196 n_faces6 = tri6_nodes.size()/6;
197 n_cells4 = tetra4_nodes.size()/4;
198 n_hexa8 = hexa8_nodes.size()/8;
199 n_cells10 = tetra10_nodes.size()/10;
201 if (n_cells4==0 && n_cells10==0 && n_hexa8==0){
202 std::cerr <<
"Your mesh is empty!\n";}
203 if ( (n_cells4>0 && n_cells10>0) || (n_cells4>0 && n_hexa8>0) || (n_cells10>0 && n_hexa8>0) ){
204 std::cerr <<
"We do not handle mixed meshes that contain tetra4's and/or tetra10's and/or hexa8's.\n";
208 if ( (n_faces3>0 && n_faces6>0) || (n_faces3>0 && n_quad4>0) || (n_faces6>0 && n_quad4>0) ){
209 std::cerr <<
"We do not handle mixed meshes that contain tri3's and/or tri6's and/or quad4's.\n";
272 std::ifstream file_bc;
273 file_bc.open(fileName_bc.c_str());
275 std::cout <<
"*ERR* Can't open the input file called " << fileName_bc.c_str() <<
"\n";
279 Epetra_IntSerialDenseVector input(number_physical_groups*
n_nodes);
280 for (
unsigned int i=0;
i<number_physical_groups*
n_nodes; ++
i){
288 for (
unsigned pg=0; pg<number_physical_groups; ++pg){
298 int check_PartMeshDual;
307 for (
unsigned int inode=0; inode<
el_type; ++inode){
328 idx_t nparts = NumProc;
332 check_PartMeshDual = METIS_PartMeshDual(&ne, &nn, eptr, eind, vwgt, vsize, &common, &nparts, tpwgts, options, &objval,
epart,
npart);
334 if (check_PartMeshDual==0){
335 std::cout <<
"*ERR* An error occured with METIS.\n";
344 return check_PartMeshDual;
361 Epetra_IntSerialDenseVector mynpart(Copy,
npart,
n_nodes);
369 for (
unsigned inode=0; inode<
el_type; ++inode){
371 if (mynpart[node]!=MyPID){
388 for (
unsigned int inode=0; inode<
face_type; ++inode){
393 if (mynpart[nodes[0]]==MyPID && mynpart[nodes[1]]==MyPID && mynpart[nodes[2]]==MyPID){
399 if (mynpart[nodes[0]]==MyPID && mynpart[nodes[1]]==MyPID && mynpart[nodes[2]]==MyPID && mynpart[nodes[3]]==MyPID){
405 if (mynpart[nodes[0]]==MyPID && mynpart[nodes[1]]==MyPID && mynpart[nodes[2]]==MyPID && mynpart[nodes[3]]==MyPID && mynpart[nodes[4]]==MyPID && mynpart[nodes[5]]==MyPID){
417 if (
Comm->MyPID()==0){
419 std::cout << std::setw(15) <<
"****************************************************\n";
420 std::cout << std::setw(15) <<
"ALERT: SOME FACES MAY BELONG TO MULTIPLE PROCESSOR!!\n";
421 std::cout << std::setw(15) <<
"SOLUTION: LOWER THE NUMBER OF PROCESSORS!!\n";
422 std::cout << std::setw(15) <<
"****************************************************\n";
432 double xi,
eta, zeta;
434 Epetra_SerialDenseVector vector_x(3);
436 Epetra_SerialDenseMatrix matrix_X(3,
el_type);
438 for (
unsigned inode=0; inode<
el_type; ++inode){
456 vector_x.Multiply(
'N',
'N',1.0,matrix_X,shape_functions,0.0);
474 for (
int inode=0; inode<
face_type; ++inode){
482 for (
int inode=0; inode<
face_type; ++inode){
490 for (
int inode=0; inode<
face_type; ++inode){
509 for (
unsigned int inode=0; inode<
face_type; ++inode){
550 Epetra_SerialDenseVector N(
el_type);
551 Epetra_SerialDenseMatrix JacobianMatrix(3,3), InverseJacobianMatrix(3,3),
X(3,
el_type), D(
el_type,3), DX(
el_type,3);
565 for (
int inode=0; inode<
el_type; ++inode){
573 for (
int inode=0; inode<
el_type; ++inode){
581 for (
int inode=0; inode<
el_type; ++inode){
590 for (
unsigned int inode=0; inode<
el_type; ++inode){
596 local_rows(3*el_type*eloc+3*inode+1) = 3*node+1;
597 local_rows(3*el_type*eloc+3*inode+2) = 3*node+2;
617 for (
int inode=0; inode<
el_type; ++inode){
618 DX_N_cells(gp+n_gauss_cells*inode,eloc) = DX(inode,0);
619 DY_N_cells(gp+n_gauss_cells*inode,eloc) = DX(inode,1);
620 DZ_N_cells(gp+n_gauss_cells*inode,eloc) = DX(inode,2);
632 Epetra_SerialDenseVector N(
el_type);
633 Epetra_SerialDenseMatrix JacobianMatrix(3,3), InverseJacobianMatrix(3,3),
X(3,
el_type), D(
el_type,3), DX(
el_type,3);
639 for (
int inode=0; inode<
el_type; ++inode){
647 for (
int inode=0; inode<
el_type; ++inode){
655 for (
int inode=0; inode<
el_type; ++inode){
664 for (
unsigned int inode=0; inode<
el_type; ++inode){
666 X(0,inode) =
nodes_coord[3*node+0] + u[OverlapMap.LID(3*node+0)];
667 X(1,inode) =
nodes_coord[3*node+1] + u[OverlapMap.LID(3*node+1)];
668 X(2,inode) =
nodes_coord[3*node+2] + u[OverlapMap.LID(3*node+2)];
669 local_rows(3*el_type*eloc+3*inode+0) = 3*node+0;
670 local_rows(3*el_type*eloc+3*inode+1) = 3*node+1;
671 local_rows(3*el_type*eloc+3*inode+2) = 3*node+2;
691 for (
int inode=0; inode<
el_type; ++inode){
692 DX_N_cells(gp+n_gauss_cells*inode,eloc) = DX(inode,0);
693 DY_N_cells(gp+n_gauss_cells*inode,eloc) = DX(inode,1);
694 DZ_N_cells(gp+n_gauss_cells*inode,eloc) = DX(inode,2);
void store_feinterp_cells()
void shape_functions(Epetra_SerialDenseVector &N, double &xi, double &eta)
std::vector< int > local_nodes
std::vector< int > local_faces
void shape_functions(Epetra_SerialDenseVector &N, double &xi, double &eta, double &zeta)
Epetra_SerialDenseVector DZ_N_cells
std::vector< double > nodes_coord
void d_shape_functions(Epetra_SerialDenseMatrix &D, double &xi, double &eta)
std::vector< int > local_dof
Epetra_SerialDenseMatrix D2_N_faces
int metis_part_mesh(int &NumProc)
Epetra_SerialDenseVector N_cells
void shape_functions(Epetra_SerialDenseVector &N, double &xi, double &eta)
void get_local_nodes(int &MyPID)
Epetra_SerialDenseVector eta_cells
Epetra_SerialDenseMatrix N_faces
Epetra_SerialDenseVector vol_cells
void d_shape_functions(Epetra_SerialDenseMatrix &D, double &xi, double &eta, double &zeta)
unsigned int n_gauss_faces
Epetra_SerialDenseVector xi_cells
Epetra_SerialDenseVector local_rows
int read_boundary_file(std::string &fileName_bc, unsigned int &number_physical_groups)
void dX_shape_functions(Epetra_SerialDenseMatrix &D, Epetra_SerialDenseMatrix JacobianMatrix, double &jac, Epetra_SerialDenseMatrix &DX)
void update_store_feinterp_cells(Epetra_Vector &u, Epetra_Map &OverlapMap)
Epetra_SerialDenseVector DX_N_cells
Epetra_SerialDenseVector detJac_cells
Epetra_IntSerialDenseMatrix nodes_to_boundaries
std::vector< int > local_cells
void d_shape_functions(Epetra_SerialDenseMatrix &D, double &xi, double &eta, double &zeta)
int n_local_nodes_without_ghosts
Epetra_SerialDenseVector xi_faces
void jacobian_det(Epetra_SerialDenseMatrix &JacobianMatrix, double &jac)
std::vector< int > faces_nodes
void gauss_points_tri3(Epetra_SerialDenseVector &weight, Epetra_SerialDenseVector &xi, Epetra_SerialDenseVector &eta)
void shape_functions(Epetra_SerialDenseVector &N, double &xi, double &eta, double &zeta)
Epetra_SerialDenseVector DY_N_cells
std::vector< int > cells_nodes
void get_cells_and_ghosts(int &MyPID)
void gauss_points_tri4(Epetra_SerialDenseVector &weight, Epetra_SerialDenseVector &xi, Epetra_SerialDenseVector &eta)
Epetra_SerialDenseMatrix D1_N_faces
void shape_functions(Epetra_SerialDenseVector &N, double &xi, double &eta)
void gauss_points_tetra4(Epetra_SerialDenseVector &weight, Epetra_SerialDenseVector &xi, Epetra_SerialDenseVector &eta, Epetra_SerialDenseVector &zeta)
unsigned int n_gauss_cells
Epetra_SerialDenseVector get_cartesian_coordinate(unsigned int &e_gid, unsigned int &gp)
void gauss_points_hexa27(Epetra_SerialDenseVector &weight, Epetra_SerialDenseVector &xi, Epetra_SerialDenseVector &eta, Epetra_SerialDenseVector &zeta)
Epetra_SerialDenseVector gauss_weight_faces
int read_gmsh(std::string &fileName_mesh, double scaling)
std::vector< int > local_nodes_without_ghosts
std::vector< int > local_dof_without_ghosts
void store_feinterp_faces()
void d_shape_functions(Epetra_SerialDenseMatrix &D, double &xi, double &eta, double &zeta)
void d_shape_functions(Epetra_SerialDenseMatrix &D, double &xi, double &eta)
void gauss_points_tetra11(Epetra_SerialDenseVector &weight, Epetra_SerialDenseVector &xi, Epetra_SerialDenseVector &eta, Epetra_SerialDenseVector &zeta)
Epetra_SerialDenseVector eta_faces
Epetra_SerialDenseVector zeta_cells
void gauss_points_quad4(Epetra_SerialDenseVector &weight, Epetra_SerialDenseVector &xi, Epetra_SerialDenseVector &eta)
Epetra_SerialDenseVector gauss_weight_cells
void jacobian_matrix(Epetra_SerialDenseMatrix &X, Epetra_SerialDenseMatrix &D, Epetra_SerialDenseMatrix &JacobianMatrix)
void d_shape_functions(Epetra_SerialDenseMatrix &D, double &xi, double &eta)
void shape_functions(Epetra_SerialDenseVector &N, double &xi, double &eta, double &zeta)