MFEM  v4.1.0
Finite element discretization library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
tmop_tools.cpp
Go to the documentation of this file.
1 // Copyright (c) 2010-2020, Lawrence Livermore National Security, LLC. Produced
2 // at the Lawrence Livermore National Laboratory. All Rights reserved. See files
3 // LICENSE and NOTICE for details. LLNL-CODE-806117.
4 //
5 // This file is part of the MFEM library. For more information and source code
6 // availability visit https://mfem.org.
7 //
8 // MFEM is free software; you can redistribute it and/or modify it under the
9 // terms of the BSD-3 license. We welcome feedback and contributions, see file
10 // CONTRIBUTING.md for details.
11 
12 #include "tmop_tools.hpp"
13 #include "nonlinearform.hpp"
14 #include "pnonlinearform.hpp"
15 #include "../general/osockstream.hpp"
16 
17 namespace mfem
18 {
19 
20 using namespace mfem;
21 
22 void AdvectorCG::SetInitialField(const Vector &init_nodes,
23  const Vector &init_field)
24 {
25  nodes0 = init_nodes;
26  field0 = init_field;
27 }
28 
30  Vector &new_field)
31 {
32 #if defined(MFEM_DEBUG) || defined(MFEM_USE_MPI)
33  int myid = 0;
34 #endif
35  Mesh *m = mesh;
36 
37 #ifdef MFEM_USE_MPI
38  if (pfes) { MPI_Comm_rank(pfes->GetComm(), &myid); }
39  if (pmesh) { m = pmesh; }
40 #endif
41 
42  MFEM_VERIFY(m != NULL, "No mesh has been given to the AdaptivityEvaluator.");
43 
44  // This will be used to move the positions.
45  GridFunction *mesh_nodes = m->GetNodes();
46  *mesh_nodes = nodes0;
47  new_field = field0;
48 
49  // Velocity of the positions.
50  GridFunction u(mesh_nodes->FESpace());
51  subtract(new_nodes, nodes0, u);
52 
53  TimeDependentOperator *oper = NULL;
54  // This must be the fes of the ind, associated with the object's mesh.
55  if (fes) { oper = new SerialAdvectorCGOper(nodes0, u, *fes); }
56 #ifdef MFEM_USE_MPI
57  else if (pfes) { oper = new ParAdvectorCGOper(nodes0, u, *pfes); }
58 #endif
59  MFEM_VERIFY(oper != NULL,
60  "No FE space has been given to the AdaptivityEvaluator.");
61  ode_solver.Init(*oper);
62 
63  // Compute some time step [mesh_size / speed].
65  for (int i = 0; i < m->GetNE(); i++)
66  {
67  min_h = std::min(min_h, m->GetElementSize(i));
68  }
69  double v_max = 0.0;
70  const int s = u.FESpace()->GetVSize() / 2;
71  for (int i = 0; i < s; i++)
72  {
73  const double vel = u(i) * u(i) + u(i+s) * u(i+s);
74  v_max = std::max(v_max, vel);
75  }
76  if (v_max == 0.0)
77  {
78  // No need to change the field.
79  return;
80  }
81  v_max = std::sqrt(v_max);
82  double dt = 0.5 * min_h / v_max;
83  double glob_dt = dt;
84 #ifdef MFEM_USE_MPI
85  if (pfes)
86  {
87  MPI_Allreduce(&dt, &glob_dt, 1, MPI_DOUBLE, MPI_MIN, pfes->GetComm());
88  }
89 #endif
90 
91  double t = 0.0;
92  bool last_step = false;
93  for (int ti = 1; !last_step; ti++)
94  {
95  if (t + glob_dt >= 1.0)
96  {
97 #ifdef MFEM_DEBUG
98  if (myid == 0)
99  {
100  mfem::out << "Remap took " << ti << " steps." << std::endl;
101  }
102 #endif
103  glob_dt = 1.0 - t;
104  last_step = true;
105  }
106  ode_solver.Step(new_field, t, glob_dt);
107  }
108 
109  // Trim the overshoots and undershoots.
110  const double minv = field0.Min(), maxv = field0.Max();
111  for (int i = 0; i < new_field.Size(); i++)
112  {
113  if (new_field(i) < minv) { new_field(i) = minv; }
114  if (new_field(i) > maxv) { new_field(i) = maxv; }
115  }
116 
117  nodes0 = new_nodes;
118  field0 = new_field;
119 
120  delete oper;
121 }
122 
124  GridFunction &vel,
125  FiniteElementSpace &fes)
126  : TimeDependentOperator(fes.GetVSize()),
127  x0(x_start), x_now(*fes.GetMesh()->GetNodes()),
128  u(vel), u_coeff(&u), M(&fes), K(&fes)
129 {
131  K.AddDomainIntegrator(Kinteg);
132  K.Assemble(0);
133  K.Finalize(0);
134 
135  MassIntegrator *Minteg = new MassIntegrator;
136  M.AddDomainIntegrator(Minteg);
137  M.Assemble();
138  M.Finalize();
139 }
140 
141 void SerialAdvectorCGOper::Mult(const Vector &ind, Vector &di_dt) const
142 {
143  // Move the mesh.
144  const double t = GetTime();
145  add(x0, t, u, x_now);
146 
147  // Assemble on the new mesh.
148  K.BilinearForm::operator=(0.0);
149  K.Assemble();
150  Vector rhs(K.Size());
151  K.Mult(ind, rhs);
152  M.BilinearForm::operator=(0.0);
153  M.Assemble();
154 
155  di_dt = 0.0;
156  CGSolver lin_solver;
157  DSmoother prec;
158  lin_solver.SetPreconditioner(prec);
159  lin_solver.SetOperator(M.SpMat());
160  lin_solver.SetRelTol(1e-12); lin_solver.SetAbsTol(0.0);
161  lin_solver.SetMaxIter(100);
162  lin_solver.SetPrintLevel(0);
163  lin_solver.Mult(rhs, di_dt);
164 }
165 
166 #ifdef MFEM_USE_MPI
168  GridFunction &vel,
169  ParFiniteElementSpace &pfes)
170  : TimeDependentOperator(pfes.GetVSize()),
171  x0(x_start), x_now(*pfes.GetMesh()->GetNodes()),
172  u(vel), u_coeff(&u), M(&pfes), K(&pfes)
173 {
175  K.AddDomainIntegrator(Kinteg);
176  K.Assemble(0);
177  K.Finalize(0);
178 
179  MassIntegrator *Minteg = new MassIntegrator;
180  M.AddDomainIntegrator(Minteg);
181  M.Assemble();
182  M.Finalize();
183 }
184 
185 void ParAdvectorCGOper::Mult(const Vector &ind, Vector &di_dt) const
186 {
187  // Move the mesh.
188  const double t = GetTime();
189  add(x0, t, u, x_now);
190 
191  // Assemble on the new mesh.
192  K.BilinearForm::operator=(0.0);
193  K.Assemble();
195  K.Mult(ind, rhs);
196  M.BilinearForm::operator=(0.0);
197  M.Assemble();
198 
199  HypreParVector *RHS = rhs.ParallelAssemble();
201  X = 0.0;
203 
204  CGSolver lin_solver(M.ParFESpace()->GetParMesh()->GetComm());
205  HypreSmoother prec;
207  lin_solver.SetPreconditioner(prec);
208  lin_solver.SetOperator(*Mh);
209  lin_solver.SetRelTol(1e-8);
210  lin_solver.SetAbsTol(0.0);
211  lin_solver.SetMaxIter(100);
212  lin_solver.SetPrintLevel(0);
213  lin_solver.Mult(*RHS, X);
214  K.ParFESpace()->GetProlongationMatrix()->Mult(X, di_dt);
215 
216  delete Mh;
217  delete RHS;
218 }
219 #endif
220 
222  const Vector &b) const
223 {
224  const FiniteElementSpace *fes = NULL;
225  double energy_in = 0.0;
226 #ifdef MFEM_USE_MPI
227  const ParNonlinearForm *p_nlf = dynamic_cast<const ParNonlinearForm *>(oper);
228  MFEM_VERIFY(!(parallel && p_nlf == NULL), "Invalid Operator subclass.");
229  if (parallel)
230  {
231  fes = p_nlf->FESpace();
232  energy_in = p_nlf->GetEnergy(x);
233  }
234 #endif
235  const bool serial = !parallel;
236  const NonlinearForm *nlf = dynamic_cast<const NonlinearForm *>(oper);
237  MFEM_VERIFY(!(serial && nlf == NULL), "Invalid Operator subclass.");
238  if (serial)
239  {
240  fes = nlf->FESpace();
241  energy_in = nlf->GetEnergy(x);
242  }
243 
244  const bool have_b = (b.Size() == Height());
245 
246  const int NE = fes->GetMesh()->GetNE(), dim = fes->GetFE(0)->GetDim(),
247  dof = fes->GetFE(0)->GetDof(), nsp = ir.GetNPoints();
248  Array<int> xdofs(dof * dim);
249  DenseMatrix Jpr(dim), dshape(dof, dim), pos(dof, dim);
250  Vector posV(pos.Data(), dof * dim);
251 
252  Vector x_out(x.Size()), x_out_loc(fes->GetVSize());
253  bool x_out_ok = false;
254  double scale = 1.0, energy_out = 0.0;
255  double norm0 = Norm(r);
256 
257  // Decreases the scaling of the update until the new mesh is valid.
258  for (int i = 0; i < 12; i++)
259  {
260  add(x, -scale, c, x_out);
261 
262  if (serial)
263  {
264  const SparseMatrix *cP = fes->GetConformingProlongation();
265  if (!cP) {x_out_loc.SetData(x_out.GetData());}
266  else {cP->Mult(x_out,x_out_loc);}
267  energy_out = nlf->GetGridFunctionEnergy(x_out_loc);
268  }
269 #ifdef MFEM_USE_MPI
270  else
271  {
272  fes->GetProlongationMatrix()->Mult(x_out, x_out_loc);
273  energy_out = p_nlf->GetParGridFunctionEnergy(x_out_loc);
274  }
275 #endif
276 
277  if (energy_out > 1.2*energy_in || std::isnan(energy_out) != 0)
278  {
279  if (print_level >= 0)
280  { mfem::out << "Scale = " << scale << " Increasing energy.\n"; }
281  scale *= 0.5; continue;
282  }
283 
284  int jac_ok = 1;
285  for (int i = 0; i < NE; i++)
286  {
287  fes->GetElementVDofs(i, xdofs);
288  x_out_loc.GetSubVector(xdofs, posV);
289  for (int j = 0; j < nsp; j++)
290  {
291  fes->GetFE(i)->CalcDShape(ir.IntPoint(j), dshape);
292  MultAtB(pos, dshape, Jpr);
293  if (Jpr.Det() <= 0.0) { jac_ok = 0; goto break2; }
294  }
295  }
296  break2:
297  int jac_ok_all = jac_ok;
298 #ifdef MFEM_USE_MPI
299  if (parallel)
300  {
301  MPI_Allreduce(&jac_ok, &jac_ok_all, 1, MPI_INT, MPI_LAND,
302  p_nlf->ParFESpace()->GetComm());
303  }
304 #endif
305 
306  if (jac_ok_all == 0)
307  {
308  if (print_level >= 0)
309  { mfem::out << "Scale = " << scale << " Neg det(J) found.\n"; }
310  scale *= 0.5; continue;
311  }
312 
313  oper->Mult(x_out, r);
314  if (have_b) { r -= b; }
315  double norm = Norm(r);
316 
317  if (norm > 1.2*norm0)
318  {
319  if (print_level >= 0)
320  { mfem::out << "Scale = " << scale << " Norm increased.\n"; }
321  scale *= 0.5; continue;
322  }
323  else { x_out_ok = true; break; }
324  }
325 
326  if (print_level >= 0)
327  {
328  mfem::out << "Energy decrease: "
329  << (energy_in - energy_out) / energy_in * 100.0
330  << "% with " << scale << " scaling.\n";
331  }
332 
333  if (x_out_ok == false) { scale = 0.0; }
334  return scale;
335 }
336 
338 {
339  if (discr_tc)
340  {
341  if (parallel)
342  {
343 #ifdef MFEM_USE_MPI
344  const ParNonlinearForm *nlf =
345  dynamic_cast<const ParNonlinearForm *>(oper);
346  Vector x_loc(nlf->ParFESpace()->GetVSize());
347  nlf->ParFESpace()->GetProlongationMatrix()->Mult(x, x_loc);
348  discr_tc->UpdateTargetSpecification(x_loc);
349 #endif
350  }
351  else { discr_tc->UpdateTargetSpecification(x); }
352  }
353 }
354 
356  const Vector &b) const
357 {
358  const FiniteElementSpace *fes = NULL;
359  double energy_in = 0.0;
360 #ifdef MFEM_USE_MPI
361  const ParNonlinearForm *p_nlf = dynamic_cast<const ParNonlinearForm *>(oper);
362  MFEM_VERIFY(!(parallel && p_nlf == NULL), "Invalid Operator subclass.");
363  if (parallel)
364  {
365  fes = p_nlf->FESpace();
366  energy_in = p_nlf->GetEnergy(x);
367  }
368 #endif
369  const bool serial = !parallel;
370  const NonlinearForm *nlf = dynamic_cast<const NonlinearForm *>(oper);
371  MFEM_VERIFY(!(serial && nlf == NULL), "Invalid Operator subclass.");
372  if (serial)
373  {
374  fes = nlf->FESpace();
375  energy_in = nlf->GetEnergy(x);
376  }
377 
378  const int NE = fes->GetMesh()->GetNE(), dim = fes->GetFE(0)->GetDim(),
379  dof = fes->GetFE(0)->GetDof(), nsp = ir.GetNPoints();
380  Array<int> xdofs(dof * dim);
381  DenseMatrix Jpr(dim), dshape(dof, dim), pos(dof, dim);
382  Vector posV(pos.Data(), dof * dim);
383  Vector x_loc(fes->GetVSize());
384 
385  double min_detJ = infinity();
386  for (int i = 0; i < NE; i++)
387  {
388  fes->GetElementVDofs(i, xdofs);
389  x_loc.GetSubVector(xdofs, posV);
390 
391  for (int j = 0; j < nsp; j++)
392  {
393  fes->GetFE(i)->CalcDShape(ir.IntPoint(j), dshape);
394  MultAtB(pos, dshape, Jpr);
395  min_detJ = std::min(min_detJ, Jpr.Det());
396  }
397  }
398  double min_detJ_all = min_detJ;
399 #ifdef MFEM_USE_MPI
400  if (parallel)
401  {
402  MPI_Allreduce(&min_detJ, &min_detJ_all, 1, MPI_DOUBLE, MPI_MIN,
403  p_nlf->ParFESpace()->GetComm());
404  }
405 #endif
406  if (print_level >= 0)
407  {
408  mfem::out << "Minimum det(J) = " << min_detJ_all << '\n';
409  }
410 
411  Vector x_out(x.Size());
412  bool x_out_ok = false;
413  double scale = 1.0, energy_out = 0.0;
414 
415  for (int i = 0; i < 7; i++)
416  {
417  add(x, -scale, c, x_out);
418  if (serial)
419  {
420  const SparseMatrix *cP = fes->GetConformingProlongation();
421  if (!cP) {x_loc.SetData(x_out.GetData());}
422  else {cP->Mult(x_out,x_loc);}
423  energy_out = nlf->GetGridFunctionEnergy(x_loc);
424  }
425 #ifdef MFEM_USE_MPI
426  else
427  {
428  fes->GetProlongationMatrix()->Mult(x_out, x_loc);
429  energy_out = p_nlf->GetParGridFunctionEnergy(x_loc);
430  }
431 #endif
432 
433  if (energy_out > energy_in || std::isnan(energy_out) != 0)
434  {
435  scale *= 0.5;
436  }
437  else { x_out_ok = true; break; }
438  }
439 
440  if (print_level >= 0)
441  {
442  mfem::out << "Energy decrease: "
443  << (energy_in - energy_out) / energy_in * 100.0
444  << "% with " << scale << " scaling.\n";
445  }
446 
447  if (x_out_ok == false) { return 0.0; }
448 
449  return scale;
450 }
451 
453 {
454  if (discr_tc)
455  {
456  if (parallel)
457  {
458 #ifdef MFEM_USE_MPI
459  const ParNonlinearForm *nlf =
460  dynamic_cast<const ParNonlinearForm *>(oper);
461  Vector x_loc(nlf->ParFESpace()->GetVSize());
462  nlf->ParFESpace()->GetProlongationMatrix()->Mult(x, x_loc);
463  discr_tc->UpdateTargetSpecification(x_loc);
464 #endif
465  }
466  else { discr_tc->UpdateTargetSpecification(x); }
467  }
468 }
469 
470 #ifdef MFEM_USE_MPI
471 // Metric values are visualized by creating an L2 finite element functions and
472 // computing the metric values at the nodes.
474  const TargetConstructor &tc, ParMesh &pmesh,
475  char *title, int position)
476 {
478  ParFiniteElementSpace fes(&pmesh, &fec, 1);
479  ParGridFunction metric(&fes);
480  InterpolateTMOP_QualityMetric(qm, tc, pmesh, metric);
481  socketstream sock;
482  if (pmesh.GetMyRank() == 0)
483  {
484  sock.open("localhost", 19916);
485  sock << "solution\n";
486  }
487  pmesh.PrintAsOne(sock);
488  metric.SaveAsOne(sock);
489  if (pmesh.GetMyRank() == 0)
490  {
491  sock << "window_title '"<< title << "'\n"
492  << "window_geometry "
493  << position << " " << 0 << " " << 600 << " " << 600 << "\n"
494  << "keys jRmclA\n";
495  }
496 }
497 #endif
498 
499 // Metric values are visualized by creating an L2 finite element functions and
500 // computing the metric values at the nodes.
502  const TargetConstructor &tc, Mesh &mesh,
503  char *title, int position)
504 {
506  FiniteElementSpace fes(&mesh, &fec, 1);
507  GridFunction metric(&fes);
508  InterpolateTMOP_QualityMetric(qm, tc, mesh, metric);
509  osockstream sock(19916, "localhost");
510  sock << "solution\n";
511  mesh.Print(sock);
512  metric.Save(sock);
513  sock.send();
514  sock << "window_title '"<< title << "'\n"
515  << "window_geometry "
516  << position << " " << 0 << " " << 600 << " " << 600 << "\n"
517  << "keys jRmclA\n";
518 }
519 
520 }
int GetNPoints() const
Returns the number of the points in the integration rule.
Definition: intrules.hpp:245
VectorGridFunctionCoefficient u_coeff
Definition: tmop_tools.hpp:47
void vis_tmop_metric_p(int order, TMOP_QualityMetric &qm, const TargetConstructor &tc, ParMesh &pmesh, char *title, int position)
Definition: tmop_tools.cpp:473
virtual double GetTime() const
Read the currently set time.
Definition: operator.hpp:300
int GetVSize() const
Return the number of vector dofs, i.e. GetNDofs() x GetVDim().
Definition: fespace.hpp:381
virtual void Print(std::ostream &out=mfem::out) const
Definition: mesh.hpp:1188
Conjugate gradient method.
Definition: solvers.hpp:152
int GetDim() const
Returns the reference space dimension for the finite element.
Definition: fe.hpp:308
ParFiniteElementSpace * ParFESpace() const
virtual void Mult(const Vector &x, Vector &y) const
Matrix vector multiplication.
Class for grid function - Vector with associated FE space.
Definition: gridfunc.hpp:27
const SparseMatrix * GetConformingProlongation() const
The returned SparseMatrix is owned by the FiniteElementSpace.
Definition: fespace.cpp:813
const Operator * oper
Definition: solvers.hpp:43
Data type for scaled Jacobi-type smoother of sparse matrix.
void Assemble(int skip_zeros=1)
Assembles the form i.e. sums over all domain/bdr integrators.
virtual void Mult(const Vector &b, Vector &x) const
Operator application: y=A(x).
Definition: solvers.cpp:358
virtual void Step(Vector &x, double &t, double &dt)
Perform a time step from time t [in] to time t [out] based on the requested step size dt [in]...
Definition: ode.cpp:109
virtual const Operator * GetProlongationMatrix() const
The returned Operator is owned by the FiniteElementSpace.
Definition: pfespace.cpp:890
void InterpolateTMOP_QualityMetric(TMOP_QualityMetric &metric, const TargetConstructor &tc, const Mesh &mesh, GridFunction &metric_gf)
Interpolates the metric&#39;s values at the nodes of metric_gf.
Definition: tmop.cpp:1436
void GetElementVDofs(int i, Array< int > &vdofs) const
Returns indexes of degrees of freedom in array dofs for i&#39;th element.
Definition: fespace.cpp:172
Base abstract class for first order time dependent operators.
Definition: operator.hpp:259
void SaveAsOne(std::ostream &out=mfem::out)
Merge the local grid functions.
Definition: pgridfunc.cpp:501
ParFiniteElementSpace * pfes
Definition: tmop.hpp:530
Data type dense matrix using column-major storage.
Definition: densemat.hpp:23
int Size() const
Returns the size of the vector.
Definition: vector.hpp:157
Parallel non-linear operator on the true dofs.
int GetNE() const
Returns number of elements.
Definition: mesh.hpp:693
virtual void Mult(const Vector &x, Vector &y) const =0
Operator application: y=A(x).
Abstract parallel finite element space.
Definition: pfespace.hpp:28
void vis_tmop_metric_s(int order, TMOP_QualityMetric &qm, const TargetConstructor &tc, Mesh &mesh, char *title, int position)
Definition: tmop_tools.cpp:501
ParBilinearForm M
Definition: tmop_tools.hpp:68
virtual double GetEnergy(const Vector &x) const
Compute the enery corresponding to the state x.
void add(const Vector &v1, const Vector &v2, Vector &v)
Definition: vector.cpp:238
double Norm(const Vector &x) const
Definition: solvers.hpp:54
HypreParMatrix * ParallelAssemble()
Returns the matrix assembled on the true dofs, i.e. P^t A P.
double t
Current time.
Definition: operator.hpp:283
virtual void ProcessNewState(const Vector &x) const
This method can be overloaded in derived classes to perform computations that need knowledge of the n...
Definition: tmop_tools.cpp:452
virtual void ComputeAtNewPosition(const Vector &new_nodes, Vector &new_field)
Definition: tmop_tools.cpp:29
virtual void Save(std::ostream &out) const
Save the GridFunction to an output stream.
Definition: gridfunc.cpp:2731
double GetEnergy(const ParGridFunction &x) const
Compute the energy of a ParGridFunction.
Abstract class for local mesh quality metrics in the target-matrix optimization paradigm (TMOP) by P...
Definition: tmop.hpp:23
IntegrationPoint & IntPoint(int i)
Returns a reference to the i-th integration point.
Definition: intrules.hpp:248
void SetPrintLevel(int print_lvl)
Definition: solvers.cpp:70
MPI_Comm GetComm() const
Definition: pfespace.hpp:239
virtual void Init(TimeDependentOperator &_f)
Associate a TimeDependentOperator with the ODE solver.
Definition: ode.cpp:100
Data type sparse matrix.
Definition: sparsemat.hpp:40
int Height() const
Get the height (size of output) of the Operator. Synonym with NumRows().
Definition: operator.hpp:57
ParBilinearForm K
Definition: tmop_tools.hpp:68
Mesh * GetMesh() const
Returns the mesh.
Definition: fespace.hpp:295
ParFiniteElementSpace * ParFESpace() const
Return the parallel FE space associated with the ParBilinearForm.
SerialAdvectorCGOper(const Vector &x_start, GridFunction &vel, FiniteElementSpace &fes)
Definition: tmop_tools.cpp:123
double b
Definition: lissajous.cpp:42
void PrintAsOne(std::ostream &out=mfem::out)
Definition: pmesh.cpp:4231
int Size() const
Get the size of the BilinearForm as a square matrix.
virtual void Mult(const Vector &ind, Vector &di_dt) const
Perform the action of the operator: y = k = f(x, t), where k solves the algebraic equation F(x...
Definition: tmop_tools.cpp:141
void SetMaxIter(int max_it)
Definition: solvers.hpp:65
virtual const Operator * GetProlongationMatrix() const
The returned Operator is owned by the FiniteElementSpace.
Definition: fespace.hpp:311
void Assemble(int skip_zeros=1)
Assemble the local matrix.
Performs a single remap advection step in serial.
Definition: tmop_tools.hpp:41
Parallel smoothers in hypre.
Definition: hypre.hpp:581
void UpdateTargetSpecification(const Vector &new_x)
Definition: tmop.cpp:960
FiniteElementSpace * FESpace()
Definition: gridfunc.hpp:442
int Dimension() const
Definition: mesh.hpp:744
double GetParGridFunctionEnergy(const Vector &x) const
Compute the energy corresponding to the state x.
FiniteElementSpace * FESpace()
double GetElementSize(int i, int type=0)
Get the size of the i-th element relative to the perfect reference element.
Definition: mesh.cpp:76
Wrapper for hypre&#39;s parallel vector class.
Definition: hypre.hpp:73
double Min() const
Returns the minimal element of the vector.
Definition: vector.cpp:1072
virtual void ProcessNewState(const Vector &x) const
This method can be overloaded in derived classes to perform computations that need knowledge of the n...
Definition: tmop_tools.cpp:337
double * Data() const
Returns the matrix data array.
Definition: densemat.hpp:96
void SetAbsTol(double atol)
Definition: solvers.hpp:64
int GetMyRank() const
Definition: pmesh.hpp:232
void SetRelTol(double rtol)
Definition: solvers.hpp:63
MPI_Comm GetComm() const
Definition: pmesh.hpp:230
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
Definition: fespace.hpp:87
int GetDof() const
Returns the number of degrees of freedom in the finite element.
Definition: fe.hpp:314
virtual void Mult(const Vector &x, Vector &y) const
Matrix vector multiplication.
Definition: sparsemat.cpp:548
ParAdvectorCGOper(const Vector &x_start, GridFunction &vel, ParFiniteElementSpace &pfes)
Definition: tmop_tools.cpp:167
void subtract(const Vector &x, const Vector &y, Vector &z)
Definition: vector.cpp:385
Performs a single remap advection step in parallel.
Definition: tmop_tools.hpp:61
double GetGridFunctionEnergy(const Vector &x) const
Compute the enery corresponding to the state x.
virtual void Finalize(int skip_zeros=1)
Finalizes the matrix initialization.
double Max() const
Returns the maximal element of the vector.
Definition: vector.cpp:799
int dim
Definition: ex24.cpp:43
virtual void SetInitialField(const Vector &init_nodes, const Vector &init_field)
Definition: tmop_tools.cpp:22
VectorGridFunctionCoefficient u_coeff
Definition: tmop_tools.hpp:67
void AddDomainIntegrator(BilinearFormIntegrator *bfi)
Adds new Domain Integrator. Assumes ownership of bfi.
const FiniteElement * GetFE(int i) const
Returns pointer to the FiniteElement associated with i&#39;th element.
Definition: fespace.cpp:1642
double infinity()
Define a shortcut for std::numeric_limits&lt;double&gt;::infinity()
Definition: vector.hpp:42
int open(const char hostname[], int port)
virtual void Mult(const Vector &ind, Vector &di_dt) const
Perform the action of the operator: y = k = f(x, t), where k solves the algebraic equation F(x...
Definition: tmop_tools.cpp:185
virtual void SetOperator(const Operator &op)
Also calls SetOperator for the preconditioner if there is one.
Definition: solvers.hpp:166
void MultAtB(const DenseMatrix &A, const DenseMatrix &B, DenseMatrix &AtB)
Multiply the transpose of a matrix A with a matrix B: At*B.
Definition: densemat.cpp:2648
Vector data type.
Definition: vector.hpp:48
void GetNodes(Vector &node_coord) const
Definition: mesh.cpp:6203
virtual double ComputeScalingFactor(const Vector &x, const Vector &b) const
This method can be overloaded in derived classes to implement line search algorithms.
Definition: tmop_tools.cpp:221
virtual void SetPreconditioner(Solver &pr)
This should be called before SetOperator.
Definition: solvers.cpp:91
const SparseMatrix & SpMat() const
Returns a reference to the sparse matrix.
Class for parallel grid function.
Definition: pgridfunc.hpp:32
Base class representing target-matrix construction algorithms for mesh optimization via the target-ma...
Definition: tmop.hpp:570
OutStream out(std::cout)
Global stream used by the library for standard output. Initially it uses the same std::streambuf as s...
Definition: globals.hpp:66
Wrapper for hypre&#39;s ParCSR matrix class.
Definition: hypre.hpp:187
virtual void CalcDShape(const IntegrationPoint &ip, DenseMatrix &dshape) const =0
Evaluate the gradients of all shape functions of a scalar finite element in reference space at the gi...
virtual double ComputeScalingFactor(const Vector &x, const Vector &b) const
This method can be overloaded in derived classes to implement line search algorithms.
Definition: tmop_tools.cpp:355
Class for parallel meshes.
Definition: pmesh.hpp:32
void SetType(HypreSmoother::Type type, int relax_times=1)
Set the relaxation type and number of sweeps.
Definition: hypre.cpp:1894
FiniteElementSpace * fes
Definition: tmop.hpp:525
Arbitrary order &quot;L2-conforming&quot; discontinuous finite elements.
Definition: fe_coll.hpp:143
alpha (q . grad u, v)