Trilinos based (stochastic) FEM solvers
phaseFieldProblem.hpp
Go to the documentation of this file.
1 /*
2 Brian Staber (brian.staber@gmail.com)
3 */
4 
5 #ifndef PHASEFIELDPROBLEM_HPP
6 #define PHASEFIELDPROBLEM_HPP
7 
9 
11 
12 public:
13 
14  phaseFieldProblem(Epetra_Comm & comm, Teuchos::ParameterList & Parameters){
15  initialize(comm, Parameters);
17  }
18 
20  }
21 
22  Epetra_SerialDenseVector get_neumannBc(Epetra_SerialDenseMatrix & matrix_X, Epetra_SerialDenseMatrix & xg, unsigned int & gp){
23  std::cout << "Not using this method in this application.\n";
24  Epetra_SerialDenseVector f(3);
25  return f;
26  }
27  Epetra_SerialDenseVector get_forcing(double & x1, double & x2, double & x3, unsigned int & e_lid, unsigned int & gp){
28  std::cout << "Not using this method in this application.\n";
29  Epetra_SerialDenseVector f(3);
30  return f;
31  }
32 
34 
35  n_bc_dof = 0;
36  double z;
37  int node;
38  for (unsigned int i=0; i<Mesh->n_local_nodes_without_ghosts; ++i){
39  node = Mesh->local_nodes[i];
40  z = Mesh->nodes_coord[3*node+2];
41  if(z<=1.0e-6 && z>=-1.0e-6){
42  n_bc_dof+=3;
43  }
44  if(z<=10+1.0e-6 && z>=10-1.0e-6){
45  n_bc_dof+=1;
46  }
47  }
48 
49  int indbc = 0;
50  dof_on_boundary = new int [n_bc_dof];
51  for (unsigned int inode=0; inode<Mesh->n_local_nodes_without_ghosts; ++inode){
52  node = Mesh->local_nodes[inode];
53  z = Mesh->nodes_coord[3*node+2];
54  if (z<=1.0e-6 && z>=-1.0e-6){
55  dof_on_boundary[indbc+0] = 3*inode+0;
56  dof_on_boundary[indbc+1] = 3*inode+1;
57  dof_on_boundary[indbc+2] = 3*inode+2;
58  indbc+=3;
59  }
60  if (z<=10+1.0e-6 && z>=10-1.0e-6){
61  dof_on_boundary[indbc+0] = 3*inode+2;
62  indbc+=1;
63  }
64  }
65 
66  }
67 
68  void apply_dirichlet_conditions(Epetra_FECrsMatrix & K, Epetra_FEVector & F, double & displacement){
69 
70  Epetra_MultiVector v(*StandardMap,true);
71  v.PutScalar(0.0);
72 
73  int node;
74  double z;
75  for (unsigned int inode=0; inode<Mesh->n_local_nodes_without_ghosts; ++inode){
76  node = Mesh->local_nodes[inode];
77  z = Mesh->nodes_coord[3*node+2];
78  if (z<=10+1.0e-6 && z>=10-1.0e-6){
79  v[0][StandardMap->LID(3*node+2)] = displacement;
80  }
81  }
82 
83  Epetra_MultiVector rhs_dir(*StandardMap,true);
84  K.Apply(v,rhs_dir);
85  F.Update(-1.0,rhs_dir,1.0);
86 
87  for (unsigned int inode=0; inode<Mesh->n_local_nodes_without_ghosts; ++inode){
88  node = Mesh->local_nodes[inode];
89  z = Mesh->nodes_coord[3*node+2];
90  if (z<=1.0e-6 && z>=-1.0e-6){
91  F[0][StandardMap->LID(3*node+0)] = 0.0;
92  F[0][StandardMap->LID(3*node+1)] = 0.0;
93  F[0][StandardMap->LID(3*node+2)] = 0.0;
94  }
95  if (z<=10+1.0e-6 && z>=10-1.0e-6){
96  F[0][StandardMap->LID(3*node+2)] = displacement;
97  }
98  }
99  //}
100  ML_Epetra::Apply_OAZToMatrix(dof_on_boundary,n_bc_dof,K);
101  }
102 
103 };
104 #endif
Epetra_SerialDenseVector get_neumannBc(Epetra_SerialDenseMatrix &matrix_X, Epetra_SerialDenseMatrix &xg, unsigned int &gp)
std::vector< int > local_nodes
Definition: meshpp.hpp:80
std::vector< double > nodes_coord
Definition: meshpp.hpp:77
Epetra_SerialDenseVector get_forcing(double &x1, double &x2, double &x3, unsigned int &e_lid, unsigned int &gp)
void initialize(Epetra_Comm &comm, Teuchos::ParameterList &Parameters)
phaseFieldProblem(Epetra_Comm &comm, Teuchos::ParameterList &Parameters)
int n_local_nodes_without_ghosts
Definition: meshpp.hpp:92
Epetra_Map * StandardMap
void apply_dirichlet_conditions(Epetra_FECrsMatrix &K, Epetra_FEVector &F, double &displacement)
for i
Definition: costFunction.m:38
e
Definition: run.m:10