22 std::string boundary_file = Teuchos::getParameter<std::string>(Parameters,
"boundary_file");
23 unsigned int number_physical_groups = Teuchos::getParameter<unsigned int>(Parameters,
"nb_phys_groups");
34 std::string mesh_file = Teuchos::getParameter<std::string>(Parameters,
"mesh_file");
35 std::string boundary_file = Teuchos::getParameter<std::string>(Parameters,
"boundary_file");
36 unsigned int number_physical_groups = Teuchos::getParameter<unsigned int>(Parameters,
"nb_phys_groups");
38 Mesh =
new mesh(comm, mesh_file, 1.0);
39 Mesh->read_boundary_file(boundary_file,number_physical_groups);
42 StandardMap =
new Epetra_Map(-1,Mesh->n_local_nodes_without_ghosts,&Mesh->local_nodes_without_ghosts[0],0,*
Comm);
43 OverlapMap =
new Epetra_Map(-1,Mesh->n_local_nodes,&Mesh->local_nodes[0],0,*
Comm);
71 FEGraph->InsertGlobalIndices(1, &index[
i], 1, &index[
j]);
81 void laplace::solve_aztec(Teuchos::ParameterList & Parameters, Epetra_FECrsMatrix & matrix, Epetra_Vector & lhs, Epetra_FEVector & rhs,
int * bc_indx,
double * bc_val){
86 Epetra_LinearProblem problem(&matrix, &lhs, &rhs);
87 AztecOO solver(problem);
89 solver.SetParameters(Parameters);
91 solver.Iterate(2000,1
e-6);
93 if (
Comm->MyPID()==0){
94 std::cout <<
"laplace problem. \n";
95 std::cout <<
"AZTEC_its \t AZTEC_res \t\t AZTEC_time \n";
96 std::cout << solver.NumIters() <<
"\t\t" << solver.TrueResidual() <<
"\t\t" << solver.SolveTime() <<
"\n";
100 void laplace::solve_amesos(Teuchos::ParameterList & Parameters, Epetra_FECrsMatrix & matrix, Epetra_Vector & lhs, Epetra_FEVector & rhs,
int * bc_indx,
double * bc_val){
102 bool display = Teuchos::getParameter<bool>(Parameters,
"display");
103 std::string solver_type = Teuchos::getParameter<std::string>(Parameters,
"solver_type");
112 Epetra_LinearProblem problem(&matrix, &lhs, &rhs);
114 Amesos_BaseSolver* Solver;
116 Solver = Factory.Create(solver_type, problem);
117 Solver->SymbolicFactorization();
118 Solver->NumericFactorization();
126 int ind_bc1 = bc_indx[0];
127 int ind_bc2 = bc_indx[1];
128 double val_bc1 = bc_val[0];
129 double val_bc2 = bc_val[1];
143 int * dofOnBoundary =
new int [n_BCDof];
148 dofOnBoundary[indbc] = inode;
154 dofOnBoundary[indbc] = inode;
162 matrix.Apply(v,rhsDir);
163 rhs.Update(-1.0,rhsDir,1.0);
175 ML_Epetra::Apply_OAZToMatrix(dofOnBoundary,n_BCDof,matrix);
176 delete[] dofOnBoundary;
181 matrix.PutScalar(0.0);
195 for (
unsigned int inode=0; inode<
Mesh->
el_type; ++inode){
197 for (
unsigned int jnode=0; jnode<
Mesh->
el_type; ++jnode){
198 Ke(inode,jnode) = 0.0;
204 for (
unsigned int inode=0; inode<
Mesh->
el_type; ++inode){
212 for (
unsigned int inode=0; inode<
Mesh->
el_type; ++inode){
213 for (
unsigned int jnode=0; jnode<
Mesh->
el_type; ++jnode){
214 error = matrix.SumIntoGlobalValues(1, &index[inode], 1, &index[jnode], &Ke(inode,jnode));
222 matrix.GlobalAssemble();
223 matrix.FillComplete();
224 rhs.GlobalAssemble();
239 double norm_phi, norm_psi;
240 Epetra_SerialDenseMatrix matrix_B(3,
Mesh->
el_type);
243 Epetra_SerialDenseVector grad_psi(3);
244 Epetra_SerialDenseVector grad_phi(3);
245 Epetra_SerialDenseMatrix matrix_X(3,
Mesh->
el_type);
247 Epetra_SerialDenseVector e0(3);
248 Epetra_SerialDenseVector e1(3);
249 Epetra_SerialDenseVector e2(3);
258 for (
unsigned int inode=0; inode<
Mesh->
el_type; ++inode){
260 phi_nodes(inode) = u_phi[
OverlapMap->LID(node)];
261 psi_nodes(inode) = u_psi[
OverlapMap->LID(node)];
267 for (
unsigned int gp=0; gp<n_gauss_points; ++gp){
268 for (
unsigned int inode=0; inode<
Mesh->
el_type; ++inode){
269 matrix_B(0,inode) =
Mesh->
DX_N_cells(gp+n_gauss_points*inode,e_lid);
270 matrix_B(1,inode) =
Mesh->
DY_N_cells(gp+n_gauss_points*inode,e_lid);
271 matrix_B(2,inode) =
Mesh->
DZ_N_cells(gp+n_gauss_points*inode,e_lid);
274 grad_phi.Multiply(
'N',
'N',1.0,matrix_B,phi_nodes,0.0);
275 grad_psi.Multiply(
'N',
'N',1.0,matrix_B,psi_nodes,0.0);
277 norm_phi = grad_phi.Norm2();
278 norm_psi = grad_psi.Norm2();
280 e0(0) = grad_phi(0)/norm_phi;
281 e0(1) = grad_phi(1)/norm_phi;
282 e0(2) = grad_phi(2)/norm_phi;
284 e2(0) = grad_psi(0)/norm_psi;
285 e2(1) = grad_psi(1)/norm_psi;
286 e2(2) = grad_psi(2)/norm_psi;
288 e1(0) = e2(1)*e0(2) - e2(2)*e0(1);
289 e1(1) = e2(2)*e0(0) - e2(0)*e0(2);
290 e1(2) = e2(0)*e0(1) - e2(1)*e0(0);
317 double norm_phi, norm_psi;
320 Epetra_SerialDenseVector grad_psi(3);
321 Epetra_SerialDenseVector grad_phi(3);
322 Epetra_SerialDenseMatrix matrix_X(3,
Mesh->
el_type);
324 Epetra_SerialDenseMatrix JacobianMatrix(3,3);
326 Epetra_SerialDenseVector e0(3);
327 Epetra_SerialDenseVector e1(3);
328 Epetra_SerialDenseVector e2(3);
335 double det_jac_cells;
353 for (
unsigned int inode=0; inode<
Mesh->
el_type; ++inode){
355 phi_nodes(inode) = u_phi[
OverlapMap->LID(node)];
356 psi_nodes(inode) = u_psi[
OverlapMap->LID(node)];
366 grad_phi.Multiply(
'T',
'N',1.0,dx_shape_functions,phi_nodes,0.0);
367 grad_psi.Multiply(
'T',
'N',1.0,dx_shape_functions,psi_nodes,0.0);
369 norm_phi = grad_phi.Norm2();
370 norm_psi = grad_psi.Norm2();
372 e0(0) = grad_phi(0)/norm_phi;
373 e0(1) = grad_phi(1)/norm_phi;
374 e0(2) = grad_phi(2)/norm_phi;
376 e2(0) = grad_psi(0)/norm_psi;
377 e2(1) = grad_psi(1)/norm_psi;
378 e2(2) = grad_psi(2)/norm_psi;
380 e1(0) = e2(1)*e0(2) - e2(2)*e0(1);
381 e1(1) = e2(2)*e0(0) - e2(0)*e0(2);
382 e1(2) = e2(0)*e0(1) - e2(1)*e0(0);
400 int NumTargetElements = 0;
401 if (
Comm->MyPID()==0){
404 Epetra_Map MapOnRoot(-1,NumTargetElements,0,*
Comm);
405 Epetra_Export ExportOnRoot(*
StandardMap,MapOnRoot);
406 Epetra_MultiVector lhs_root(MapOnRoot,
true);
407 lhs_root.Export(lhs,ExportOnRoot,Insert);
408 int error = EpetraExt::MultiVectorToMatrixMarketFile(fileName.c_str(),lhs_root,0,0,
false);
void assembling_OAZ(Epetra_FECrsMatrix &matrix, Epetra_FEVector &rhs, int *bc_indx, double *bc_val)
std::vector< int > local_nodes
Epetra_SerialDenseVector DZ_N_cells
std::vector< double > nodes_coord
void assembling(Epetra_FECrsMatrix &matrix, Epetra_FEVector &rhs)
int print_solution(Epetra_Vector &lhs, std::string fileName)
void compute_center_local_directions(Epetra_Vector &laplace_one, Epetra_Vector &laplace_two)
void d_shape_functions(Epetra_SerialDenseMatrix &D, double &xi, double &eta, double &zeta)
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)
Epetra_SerialDenseVector DX_N_cells
Epetra_SerialDenseVector detJac_cells
Epetra_FECrsGraph * FEGraph
Epetra_IntSerialDenseMatrix nodes_to_boundaries
Epetra_SerialDenseMatrix laplace_direction_two_center
std::vector< int > local_cells
clc clear all close all mesh
void d_shape_functions(Epetra_SerialDenseMatrix &D, double &xi, double &eta, double &zeta)
int n_local_nodes_without_ghosts
void jacobian_det(Epetra_SerialDenseMatrix &JacobianMatrix, double &jac)
Epetra_SerialDenseVector DY_N_cells
std::vector< int > cells_nodes
Epetra_SerialDenseMatrix laplace_direction_two
Epetra_SerialDenseMatrix laplace_direction_one
Epetra_Import * ImportToOverlapMap
unsigned int n_gauss_cells
Epetra_SerialDenseMatrix laplace_direction_two_cross_one
Epetra_SerialDenseMatrix laplace_direction_one_center
std::vector< int > local_nodes_without_ghosts
Epetra_SerialDenseMatrix laplace_direction_two_cross_one_center
void compute_local_directions(Epetra_Vector &laplace_one, Epetra_Vector &laplace_two)
void solve_amesos(Teuchos::ParameterList &Parameters, Epetra_FECrsMatrix &matrix, Epetra_Vector &lhs, Epetra_FEVector &rhs, int *bc_indx, double *bc_val)
void d_shape_functions(Epetra_SerialDenseMatrix &D, double &xi, double &eta, double &zeta)
Epetra_SerialDenseVector gauss_weight_cells
void jacobian_matrix(Epetra_SerialDenseMatrix &X, Epetra_SerialDenseMatrix &D, Epetra_SerialDenseMatrix &JacobianMatrix)
void solve_aztec(Teuchos::ParameterList &Parameters, Epetra_FECrsMatrix &matrix, Epetra_Vector &lhs, Epetra_FEVector &rhs, int *bc_indx, double *bc_val)