www.mooseframework.org
Public Member Functions | List of all members
GrandPotentialKernelAction Class Reference

#include <GrandPotentialKernelAction.h>

Inheritance diagram for GrandPotentialKernelAction:
[legend]

Public Member Functions

 GrandPotentialKernelAction (const InputParameters &parameters)
 
virtual void act ()
 

Detailed Description

Definition at line 38 of file GrandPotentialKernelAction.h.

Constructor & Destructor Documentation

◆ GrandPotentialKernelAction()

GrandPotentialKernelAction::GrandPotentialKernelAction ( const InputParameters &  parameters)

Definition at line 73 of file GrandPotentialKernelAction.C.

74  : Action(parameters)
75 {
76 }

Member Function Documentation

◆ act()

void GrandPotentialKernelAction::act ( )
virtual

Definition at line 79 of file GrandPotentialKernelAction.C.

80 {
81  // Get Variables from parameters
82  const auto w_names = getParam<std::vector<NonlinearVariableName>>("chemical_potentials");
83  const auto chis = getParam<std::vector<MaterialPropertyName>>("susceptibilities");
84  const auto Fj_gr = getParam<std::vector<MaterialPropertyName>>("free_energies_gr");
85  const auto Fj_w = getParam<std::vector<MaterialPropertyName>>("free_energies_w");
86  const auto hj = getParam<std::vector<MaterialPropertyName>>("switching_function_names");
87  const auto M = getParam<std::vector<MaterialPropertyName>>("mobilities");
88  auto n_grs = getParam<unsigned int>("op_num");
89  const auto var_name_base = getParam<std::string>("var_name_base");
90  const auto Fj_op = getParam<std::vector<MaterialPropertyName>>("free_energies_op");
91  const auto kappa_gr = getParam<MaterialPropertyName>("kappa_gr");
92  const auto kappa_op = getParam<MaterialPropertyName>("kappa_op");
93  const auto gamma_gr = getParam<MaterialPropertyName>("gamma_gr");
94  const auto gamma_op = getParam<MaterialPropertyName>("gamma_op");
95  const auto gamma_xx = getParam<MaterialPropertyName>("gamma_grxop");
96  const auto gr_mob = getParam<MaterialPropertyName>("mobility_name_gr");
97  const auto op_mob = getParam<MaterialPropertyName>("mobility_name_op");
98  auto implicity = getParam<bool>("implicit");
99  auto displaced_mesh = getParam<bool>("use_displaced_mesh");
100  auto aniso = getParam<bool>("anisotropic");
101 
102  // Size definitions and checks
103  unsigned int n_w = w_names.size();
104  unsigned int n_hj = hj.size();
105  std::vector<NonlinearVariableName> etas;
106  unsigned int n_etas = 0;
107  std::string kernel_name;
108  if (isParamValid("additional_ops"))
109  {
110  etas = getParam<std::vector<NonlinearVariableName>>("additional_ops");
111  n_etas = etas.size();
112  }
113 
114  if (chis.size() != n_w)
115  mooseError("susceptibilities and chemical_potentials should be vectors of the same length.");
116  if (Fj_w.size() != n_w * n_hj)
117  mooseError("free_energies_w should be length of chemcial_potentials * length of "
118  "switching_function_names");
119  if (M.size() != n_w)
120  mooseError("M and chemical_potentials should be vectors of the same length.");
121 
122  // Define additional vectors
123  std::vector<std::string> grs; // vector of all grain variable names
124  grs.resize(n_grs);
125  for (unsigned int i = 0; i < n_grs; ++i)
126  grs[i] = var_name_base + Moose::stringify(i);
127 
128  std::vector<NonlinearVariableName> all_etas; // vector of all grain variables and order parameters
129  all_etas.reserve(n_etas + n_grs);
130  all_etas.insert(all_etas.end(), etas.begin(), etas.end());
131  all_etas.insert(all_etas.end(), grs.begin(), grs.end());
132 
133  std::vector<std::string> all_vars; // vector of all variables
134  all_vars.reserve(n_etas + n_grs + n_w);
135  all_vars.insert(all_vars.end(), all_etas.begin(), all_etas.end());
136  all_vars.insert(all_vars.end(), w_names.begin(), w_names.end());
137 
138  std::vector<MaterialPropertyName> fj_temp;
139  fj_temp.resize(n_hj);
140  std::vector<VariableName> notarealvector;
141  notarealvector.resize(1);
142  std::vector<VariableName> v0;
143  v0.resize(n_etas + n_grs + n_w);
144  for (unsigned int i = 0; i < n_etas + n_grs + n_w; ++i)
145  v0[i] = all_vars[i];
146  std::vector<VariableName> v1;
147  v1.resize(n_etas + n_grs);
148  for (unsigned int i = 0; i < n_etas + n_grs; ++i)
149  v1[i] = all_etas[i];
150  std::vector<VariableName> v2;
151  v2.resize(n_etas + n_grs - 1);
152 
153  // Grains and order parameters
154  NonlinearVariableName var_name;
155  MaterialPropertyName kappa;
156  MaterialPropertyName mob_name;
157  std::vector<MaterialPropertyName> Fj_names;
158 
159  for (unsigned int i = 0; i < n_etas + n_grs; ++i)
160  {
161  var_name = all_etas[i];
162  // Distinguish between grains and the additional order parameters
163  if (i < n_etas) // First part of list is grain variables
164  {
165  kappa = kappa_op;
166  mob_name = op_mob;
167  Fj_names.resize(Fj_op.size());
168  Fj_names = Fj_op;
169  }
170  else // Second part of list is additional order parameters
171  {
172  kappa = kappa_gr;
173  mob_name = gr_mob;
174  Fj_names.resize(Fj_gr.size());
175  Fj_names = Fj_gr;
176  }
177 
178  // Remove var_name from coupled variables
179  std::vector<MaterialPropertyName> gam;
180  gam.resize(n_etas + n_grs - 1);
181  unsigned int op = 0;
182  for (unsigned int j = 0; j < n_etas + n_grs; ++j)
183  {
184  if (i != j)
185  {
186  v2[op] = all_etas[j];
187  if (j < n_etas)
188  gam[op] = gamma_op;
189  else
190  gam[op] = gamma_gr;
191  if (i < n_etas && j < n_etas)
192  gam[op] = gamma_op;
193  else if (i >= n_etas && j >= n_etas)
194  gam[op] = gamma_gr;
195  else
196  gam[op] = gamma_xx;
197  ++op;
198  }
199  }
200 
201  // TimeDerivative Kernel
202  InputParameters params = _factory.getValidParams("TimeDerivative");
203  params.set<NonlinearVariableName>("variable") = var_name;
204  params.set<bool>("implicit") = implicity;
205  params.set<bool>("use_displaced_mesh") = displaced_mesh;
206  kernel_name = "DT_" + var_name;
207  _problem->addKernel("TimeDerivative", kernel_name, params);
208 
209  // ACInterface Kernel
210  params = _factory.getValidParams("ACInterface");
211  params.set<NonlinearVariableName>("variable") = var_name;
212  params.set<bool>("implicit") = implicity;
213  params.set<bool>("use_displaced_mesh") = displaced_mesh;
214  params.set<MaterialPropertyName>("kappa_name") = kappa;
215  params.set<MaterialPropertyName>("mob_name") = mob_name;
216  params.set<std::vector<VariableName>>("args") = v2;
217  kernel_name = "ACInt_" + var_name;
218  _problem->addKernel("ACInterface", kernel_name, params);
219 
220  // ACSwitching Kernel
221  params = _factory.getValidParams("ACSwitching");
222  params.set<NonlinearVariableName>("variable") = var_name;
223  params.set<bool>("implicit") = implicity;
224  params.set<bool>("use_displaced_mesh") = displaced_mesh;
225  params.set<std::vector<MaterialPropertyName>>("Fj_names") = Fj_names;
226  params.set<std::vector<MaterialPropertyName>>("hj_names") = hj;
227  params.set<MaterialPropertyName>("mob_name") = mob_name;
228  params.set<std::vector<VariableName>>("args") = v0;
229  kernel_name = "ACSwitch_" + var_name;
230  _problem->addKernel("ACSwitching", kernel_name, params);
231 
232  // ACGrGrMulti Kernel
233  params = _factory.getValidParams("ACGrGrMulti");
234  params.set<NonlinearVariableName>("variable") = var_name;
235  params.set<bool>("implicit") = implicity;
236  params.set<bool>("use_displaced_mesh") = displaced_mesh;
237  params.set<MaterialPropertyName>("mob_name") = mob_name;
238  params.set<std::vector<VariableName>>("v") = v2;
239  params.set<std::vector<MaterialPropertyName>>("gamma_names") = gam;
240  kernel_name = "AcGrGr_" + var_name;
241  _problem->addKernel("ACGrGrMulti", kernel_name, params);
242  } // for (unsigned int i = 0; i < n_etas + n_grs; ++i)
243 
244  // Chemical Potentials
245  for (unsigned int i = 0; i < n_w; ++i)
246  {
247  // SusceptibilityTimeDerivative
248  InputParameters params = _factory.getValidParams("SusceptibilityTimeDerivative");
249  params.set<NonlinearVariableName>("variable") = w_names[i];
250  params.set<MaterialPropertyName>("f_name") = chis[i];
251  params.set<std::vector<VariableName>>("args") = v1;
252  params.set<bool>("implicit") = implicity;
253  params.set<bool>("use_displaced_mesh") = displaced_mesh;
254  kernel_name = "ChiDt_" + w_names[i];
255  _problem->addKernel("SusceptibilityTimeDerivative", kernel_name, params);
256 
257  // MatDiffusion
258  params = _factory.getValidParams("MatDiffusion");
259  params.set<NonlinearVariableName>("variable") = w_names[i];
260  params.set<bool>("implicit") = implicity;
261  params.set<bool>("use_displaced_mesh") = displaced_mesh;
262  params.set<MaterialPropertyName>("D_name") = M[i];
263  kernel_name = "MatDif_" + w_names[i];
264  if (aniso)
265  _problem->addKernel("MatAnisoDiffusion", kernel_name, params);
266  else
267  _problem->addKernel("MatDiffusion", kernel_name, params);
268 
269  // CoupledSwitchingTimeDerivative
270  for (unsigned int j = 0; j < n_hj; ++j)
271  fj_temp[j] = Fj_w[i * n_hj + j];
272  for (unsigned int j = 0; j < n_etas + n_grs; ++j)
273  {
274  notarealvector[0] = all_etas[j];
275  params = _factory.getValidParams("CoupledSwitchingTimeDerivative");
276  params.set<NonlinearVariableName>("variable") = w_names[i];
277  params.set<std::vector<VariableName>>("v") = notarealvector;
278  params.set<std::vector<VariableName>>("args") = v1;
279  params.set<std::vector<MaterialPropertyName>>("Fj_names") = fj_temp;
280  params.set<std::vector<MaterialPropertyName>>("hj_names") = hj;
281  params.set<bool>("implicit") = implicity;
282  params.set<bool>("use_displaced_mesh") = displaced_mesh;
283  kernel_name = "Coupled_" + w_names[i] + "_" + all_etas[j];
284  _problem->addKernel("CoupledSwitchingTimeDerivative", kernel_name, params);
285  }
286  }
287 } // GrandPotentialKernelAction::act()

The documentation for this class was generated from the following files: