MFEM v4.7.0
Finite element discretization library
Loading...
Searching...
No Matches
extrapolator.cpp
Go to the documentation of this file.
1// Copyright (c) 2010-2024, 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 "extrapolator.hpp"
14#include "marking.hpp"
15
16using namespace std;
17
18namespace mfem
19{
20
21const char vishost[] = "localhost";
22const int visport = 19916;
23int wsize = 350; // glvis window size
24
26 ParBilinearForm &Kbf, const Vector &rhs)
27 : TimeDependentOperator(Mbf.Size()),
28 active_zones(zones),
29 M(Mbf), K(Kbf), K_mat(NULL), b(rhs),
30 lo_solver(NULL), lumpedM(NULL)
31{
32 K_mat = K.ParallelAssemble(&K.SpMat());
33
34 ParBilinearForm M_Lump(M.ParFESpace());
35 lumpedM = new Vector;
37 M_Lump.Assemble();
38 M_Lump.Finalize();
39 M_Lump.SpMat().GetDiag(*lumpedM);
40 lo_solver = new DiscreteUpwindLOSolver(*M.ParFESpace(),
41 K.SpMat(), *lumpedM);
42}
43
45{
46 delete lo_solver;
47 delete lumpedM;
48 delete K_mat;
49}
50
51void AdvectionOper::Mult(const Vector &x, Vector &dx) const
52{
54 const int NE = pfes.GetNE();
55 const int nd = pfes.GetFE(0)->GetDof();
56 Array<int> dofs(nd);
57
58 if (adv_mode == LO)
59 {
60 lo_solver->CalcLOSolution(x, b, dx);
61 for (int k = 0; k < NE; k++)
62 {
63 pfes.GetElementDofs(k, dofs);
64 if (active_zones[k] == false)
65 {
66 dx.SetSubVector(dofs, 0.0);
67 continue;
68 }
69 }
70 return;
71 }
72
73 MFEM_VERIFY(adv_mode == HO, "Wrong input for advection mode (-dg).");
74
75 Vector rhs(x.Size());
76 K_mat->Mult(x, rhs);
77 rhs += b;
78
79 DenseMatrix M_loc(nd);
80 DenseMatrixInverse M_loc_inv(&M_loc);
81 Vector rhs_loc(nd), dx_loc(nd);
82 for (int k = 0; k < NE; k++)
83 {
84 pfes.GetElementDofs(k, dofs);
85
86 if (active_zones[k] == false)
87 {
88 dx.SetSubVector(dofs, 0.0);
89 continue;
90 }
91
92 rhs.GetSubVector(dofs, rhs_loc);
93 M.SpMat().GetSubMatrix(dofs, dofs, M_loc);
94 M_loc_inv.Factor();
95 M_loc_inv.Mult(rhs_loc, dx_loc);
96 dx.SetSubVector(dofs, dx_loc);
97 }
98}
99
100void AdvectionOper::ComputeElementsMinMax(const ParGridFunction &gf,
101 Vector &el_min, Vector &el_max) const
102{
103 ParFiniteElementSpace &pfes = *gf.ParFESpace();
104 const int NE = pfes.GetNE(), ndof = pfes.GetFE(0)->GetDof();
105 for (int k = 0; k < NE; k++)
106 {
107 el_min(k) = numeric_limits<real_t>::infinity();
108 el_max(k) = -numeric_limits<real_t>::infinity();
109
110 for (int i = 0; i < ndof; i++)
111 {
112 el_min(k) = min(el_min(k), gf(k*ndof + i));
113 el_max(k) = max(el_max(k), gf(k*ndof + i));
114 }
115 }
116}
117
118void AdvectionOper::ComputeBounds(const ParFiniteElementSpace &pfes,
119 const Vector &el_min, const Vector &el_max,
120 Vector &dof_min, Vector &dof_max) const
121{
122 ParMesh *pmesh = pfes.GetParMesh();
123 L2_FECollection fec_bounds(0, pmesh->Dimension());
124 ParFiniteElementSpace pfes_bounds(pmesh, &fec_bounds);
125 ParGridFunction el_min_gf(&pfes_bounds), el_max_gf(&pfes_bounds);
126 const int NE = pmesh->GetNE(), ndofs = dof_min.Size() / NE;
127
128 el_min_gf = el_min;
129 el_max_gf = el_max;
130
131 el_min_gf.ExchangeFaceNbrData(); el_max_gf.ExchangeFaceNbrData();
132 const Vector &min_nbr = el_min_gf.FaceNbrData();
133 const Vector &max_nbr = el_max_gf.FaceNbrData();
134 const Table &el_to_el = pmesh->ElementToElementTable();
135 Array<int> face_nbr_el;
136 for (int k = 0; k < NE; k++)
137 {
138 real_t k_min = el_min_gf(k), k_max = el_max_gf(k);
139
140 el_to_el.GetRow(k, face_nbr_el);
141 for (int n = 0; n < face_nbr_el.Size(); n++)
142 {
143 if (face_nbr_el[n] < NE)
144 {
145 // Local neighbor.
146 k_min = std::min(k_min, el_min_gf(face_nbr_el[n]));
147 k_max = std::max(k_max, el_max_gf(face_nbr_el[n]));
148 }
149 else
150 {
151 // MPI face neighbor.
152 k_min = std::min(k_min, min_nbr(face_nbr_el[n] - NE));
153 k_max = std::max(k_max, max_nbr(face_nbr_el[n] - NE));
154 }
155 }
156
157 for (int j = 0; j < ndofs; j++)
158 {
159 dof_min(k*ndofs + j) = k_min;
160 dof_max(k*ndofs + j) = k_max;
161 }
162 }
163}
164
166 const ParGridFunction &input,
167 const real_t time_period,
168 ParGridFunction &xtrap)
169{
170 ParMesh &pmesh = *input.ParFESpace()->GetParMesh();
171 const int order = input.ParFESpace()->GetOrder(0),
172 dim = pmesh.Dimension(), NE = pmesh.GetNE();
173
174 // Get a ParGridFunction and mark elements.
175 H1_FECollection fec(order, dim);
176 ParFiniteElementSpace pfes_H1(&pmesh, &fec);
177 ParGridFunction ls_gf(&pfes_H1);
178 ls_gf.ProjectCoefficient(level_set);
179 if (visualization)
180 {
181 socketstream sock1, sock2;
183 "Domain level set", 0, 0, wsize, wsize,
184 "rRjlmm********A");
186 "Input u", 0, wsize+60, wsize, wsize,
187 "rRjlmm********A");
188 MPI_Barrier(pmesh.GetComm());
189 }
190 // Mark elements.
191 Array<int> elem_marker;
192 ShiftedFaceMarker marker(pmesh, pfes_H1, false);
193 ls_gf.ExchangeFaceNbrData();
194 marker.MarkElements(ls_gf, elem_marker);
195
196 // The active zones are where we extrapolate (where the PDE is solved).
197 Array<bool> active_zones(NE);
198 for (int k = 0; k < NE; k++)
199 {
200 // Extrapolation is done in zones that are CUT or OUTSIDE.
201 active_zones[k] =
202 (elem_marker[k] == ShiftedFaceMarker::INSIDE) ? false : true;
203 }
204
205 // Setup a VectorCoefficient for n = - grad_ls / |grad_ls|.
206 // The sign makes it point out of the known region.
207 // The coefficient must be continuous to have well-defined transport.
208 LevelSetNormalGradCoeff ls_n_coeff_L2(ls_gf);
209 ParFiniteElementSpace pfes_H1_vec(&pmesh, &fec, dim);
210 ParGridFunction lsn_gf(&pfes_H1_vec);
211 ls_gf.ExchangeFaceNbrData();
213 VectorGridFunctionCoefficient ls_n_coeff(&lsn_gf);
214
215 // Initial solution.
216 // Trim to the known values (only elements inside the known region).
217 Array<int> dofs;
218 L2_FECollection fec_L2(order, dim);
219 ParFiniteElementSpace pfes_L2(&pmesh, &fec_L2);
220 ParGridFunction u(&pfes_L2), vis_marking(&pfes_L2);
221 u.ProjectGridFunction(input);
222 for (int k = 0; k < NE; k++)
223 {
224 pfes_L2.GetElementDofs(k, dofs);
225 if (elem_marker[k] != ShiftedFaceMarker::INSIDE)
226 { u.SetSubVector(dofs, 0.0); }
227 vis_marking.SetSubVector(dofs, elem_marker[k]);
228 }
229 if (visualization)
230 {
231 socketstream sock1, sock2;
233 "Fixed (known) u values", wsize, 0,
234 wsize, wsize, "rRjlmm********A");
235 common::VisualizeField(sock2, vishost, visport, vis_marking,
236 "Element markings", 0, 2*wsize+60,
237 wsize, wsize, "rRjlmm********A");
238 }
239
240 // Normal derivative function.
241 ParGridFunction n_grad_u(&pfes_L2);
242 NormalGradCoeff n_grad_u_coeff(u, ls_n_coeff);
243 n_grad_u.ProjectCoefficient(n_grad_u_coeff);
244 if (visualization && xtrap_degree >= 1)
245 {
246 socketstream sock;
247 common::VisualizeField(sock, vishost, visport, n_grad_u,
248 "n.grad(u)", 2*wsize, 0, wsize, wsize,
249 "rRjlmm********A");
250 }
251
252 // 2nd normal derivative function.
253 ParGridFunction n_grad_n_grad_u(&pfes_L2);
254 NormalGradCoeff n_grad_n_grad_u_coeff(n_grad_u, ls_n_coeff);
255 n_grad_n_grad_u.ProjectCoefficient(n_grad_n_grad_u_coeff);
256 if (visualization && xtrap_degree == 2)
257 {
258 socketstream sock;
259 common::VisualizeField(sock, vishost, visport, n_grad_n_grad_u,
260 "n.grad(n.grad(u))", 3*wsize, 0, wsize, wsize,
261 "rRjmm********A");
262 }
263
264 ParBilinearForm lhs_bf(&pfes_L2), rhs_bf(&pfes_L2);
265 lhs_bf.AddDomainIntegrator(new MassIntegrator);
266 const real_t alpha = -1.0;
267 rhs_bf.AddDomainIntegrator(new ConvectionIntegrator(ls_n_coeff, alpha));
268 auto trace_i = new NonconservativeDGTraceIntegrator(ls_n_coeff, alpha);
269 rhs_bf.AddInteriorFaceIntegrator(trace_i);
270 rhs_bf.KeepNbrBlock(true);
271
272 ls_gf.ExchangeFaceNbrData();
273 lhs_bf.Assemble();
274 lhs_bf.Finalize();
275 rhs_bf.Assemble(0);
276 rhs_bf.Finalize(0);
277
278 // Compute a CFL time step.
279 real_t h_min = std::numeric_limits<real_t>::infinity();
280 for (int k = 0; k < NE; k++)
281 {
282 h_min = std::min(h_min, pmesh.GetElementSize(k));
283 }
284 MPI_Allreduce(MPI_IN_PLACE, &h_min, 1, MPITypeMap<real_t>::mpi_type, MPI_MIN,
285 pmesh.GetComm());
286 // The propagation speed is 1.
287 real_t dt = 0.25 * h_min / order / 1.0;
288 real_t half_dt = 0.5 * dt;
290 {
291 dt = half_dt;
292 }
293
294 // Time loops.
295 Vector rhs(pfes_L2.GetVSize());
296 AdvectionOper adv_oper(active_zones, lhs_bf, rhs_bf, rhs);
297 adv_oper.adv_mode = advection_mode;
298 RK2Solver ode_solver(1.0);
299 ode_solver.Init(adv_oper);
300
301 if (xtrap_degree == 0)
302 {
303 // Constant extrapolation of u (always LO).
304 rhs = 0.0;
305 adv_oper.adv_mode = AdvectionOper::LO;
306 TimeLoop(u, ode_solver, time_period, half_dt,
307 wsize, "Extrap const u -- LO");
308 xtrap.ProjectGridFunction(u);
309 return;
310 }
311
312 std::string mode_text = "HO";
313 if (advection_mode == AdvectionOper::LO) { mode_text = "LO"; }
314
315 MFEM_VERIFY(xtrap_degree == 1 || xtrap_degree == 2, "Wrong order input.");
316 if (xtrap_type == ASLAM)
317 {
318 if (xtrap_degree == 1)
319 {
320 // Constant extrapolation of [n.grad_u] (always LO).
321 rhs = 0.0;
322 adv_oper.adv_mode = AdvectionOper::LO;
323 TimeLoop(n_grad_u, ode_solver, time_period, half_dt,
324 2*wsize, "Extrap const n.grad(u) -- Aslam -- LO");
325
326 adv_oper.adv_mode = advection_mode;
327
328 // Linear extrapolation of u.
329 lhs_bf.Mult(n_grad_u, rhs);
330 TimeLoop(u, ode_solver, time_period, dt,
331 wsize, "Extrap linear u -- Aslam -- " + mode_text);
332 }
333
334 if (xtrap_degree == 2)
335 {
336 // Constant extrapolation of [n.grad(n.grad(u))] (always LO).
337 rhs = 0.0;
338 adv_oper.adv_mode = AdvectionOper::LO;
339 TimeLoop(n_grad_n_grad_u, ode_solver, time_period, half_dt,
340 3*wsize, "Extrap const n.grad(n.grad(u)) -- Aslam -- LO");
341
342 adv_oper.adv_mode = advection_mode;
343
344 // Linear extrapolation of [n.grad_u].
345 lhs_bf.Mult(n_grad_n_grad_u, rhs);
346 TimeLoop(n_grad_u, ode_solver, time_period, dt,
347 2*wsize, "Extrap linear n.grad(u) -- Aslam -- " + mode_text);
348
349 // Quadratic extrapolation of u.
350 lhs_bf.Mult(n_grad_u, rhs);
351 TimeLoop(u, ode_solver, time_period, dt,
352 wsize, "Extrap quadratic u -- Aslam -- " + mode_text);
353 }
354 }
355 else if (xtrap_type == BOCHKOV)
356 {
357 if (xtrap_degree == 1)
358 {
359 // Constant extrapolation of all grad(u) components (always LO).
360 rhs = 0.0;
361 adv_oper.adv_mode = AdvectionOper::LO;
362 ParGridFunction grad_u_0(&pfes_L2), grad_u_1(&pfes_L2);
363 GradComponentCoeff grad_u_0_coeff(u, 0), grad_u_1_coeff(u, 1);
364 grad_u_0.ProjectCoefficient(grad_u_0_coeff);
365 grad_u_1.ProjectCoefficient(grad_u_1_coeff);
366 TimeLoop(grad_u_0, ode_solver, time_period, half_dt,
367 2*wsize, "Extrap const du_dx -- Bochkov -- LO");
368 TimeLoop(grad_u_1, ode_solver, time_period, half_dt,
369 3*wsize, "Extrap const du_dy -- Bochkov -- LO");
370
371 adv_oper.adv_mode = advection_mode;
372
373 // Linear extrapolation of u.
374 ParLinearForm rhs_lf(&pfes_L2);
375 NormalGradComponentCoeff grad_u_n(grad_u_0, grad_u_1, ls_n_coeff);
376 rhs_lf.AddDomainIntegrator(new DomainLFIntegrator(grad_u_n));
377 rhs_lf.Assemble();
378 rhs = rhs_lf;
379 TimeLoop(u, ode_solver, time_period, dt,
380 wsize, "Extrap linear u -- Bochkov -- " + mode_text);
381 }
382
383 if (xtrap_degree == 2)
384 {
385 MFEM_ABORT("Quadratic Bochkov method is not implemented.");
386 }
387 }
388 else { MFEM_ABORT("Wrong input for extrapolation type (-et)."); }
389
390 xtrap.ProjectGridFunction(u);
391}
392
393// Errors in cut elements.
395 const ParGridFunction &exact,
396 const ParGridFunction &xtrap,
397 real_t &err_L1, real_t &err_L2,
398 real_t &err_LI)
399{
400 ParMesh &pmesh = *exact.ParFESpace()->GetParMesh();
401 const int order = exact.ParFESpace()->GetOrder(0),
402 dim = pmesh.Dimension(), NE = pmesh.GetNE();
403
404 // Get a ParGridFunction and mark elements.
405 H1_FECollection fec(order, dim);
406 ParFiniteElementSpace pfes_H1(&pmesh, &fec);
407 ParGridFunction ls_gf(&pfes_H1);
408 ls_gf.ProjectCoefficient(level_set);
409 // Mark elements.
410 Array<int> elem_marker;
411 ShiftedFaceMarker marker(pmesh, pfes_H1, false);
412 ls_gf.ExchangeFaceNbrData();
413 marker.MarkElements(ls_gf, elem_marker);
414
415 Vector errors_L1(NE), errors_L2(NE), errors_LI(NE);
416 GridFunctionCoefficient exact_coeff(&exact);
417
418 xtrap.ComputeElementL1Errors(exact_coeff, errors_L1);
419 xtrap.ComputeElementL2Errors(exact_coeff, errors_L2);
420 xtrap.ComputeElementMaxErrors(exact_coeff, errors_LI);
421 err_L1 = 0.0, err_L2 = 0.0, err_LI = 0.0;
422 real_t cut_volume = 0.0;
423 for (int k = 0; k < NE; k++)
424 {
425 if (elem_marker[k] == ShiftedFaceMarker::CUT)
426 {
427 err_L1 += errors_L1(k);
428 err_L2 += errors_L2(k);
429 err_LI = std::max(err_LI, errors_LI(k));
430 cut_volume += pmesh.GetElementVolume(k);
431 }
432 }
433 MPI_Comm comm = pmesh.GetComm();
434 MPI_Allreduce(MPI_IN_PLACE, &err_L1, 1, MPITypeMap<real_t>::mpi_type,
435 MPI_SUM, comm);
436 MPI_Allreduce(MPI_IN_PLACE, &err_L2, 1, MPITypeMap<real_t>::mpi_type,
437 MPI_SUM, comm);
438 MPI_Allreduce(MPI_IN_PLACE, &err_LI, 1, MPITypeMap<real_t>::mpi_type,
439 MPI_MAX, comm);
440 MPI_Allreduce(MPI_IN_PLACE, &cut_volume, 1, MPITypeMap<real_t>::mpi_type,
441 MPI_SUM, comm);
442 err_L1 /= cut_volume;
443 err_L2 /= cut_volume;
444}
445
446void Extrapolator::TimeLoop(ParGridFunction &sltn, ODESolver &ode_solver,
447 real_t t_final, real_t dt,
448 int vis_x_pos, std::string vis_name)
449{
450 socketstream sock;
451
452 const int myid = sltn.ParFESpace()->GetMyRank();
453 bool done = false;
454 real_t t = 0.0;
455 for (int ti = 0; !done;)
456 {
457 real_t dt_real = min(dt, t_final - t);
458 ode_solver.Step(sltn, t, dt_real);
459 ti++;
460
461 done = (t >= t_final - 1e-8*dt);
462 if (done || ti % vis_steps == 0)
463 {
464 if (myid == 0)
465 {
466 cout << vis_name+" / time step: " << ti << ", time: " << t << endl;
467 }
468 if (visualization)
469 {
471 vis_name.c_str(), vis_x_pos, wsize+60,
472 wsize, wsize, "rRjlmm********A");
473 MPI_Barrier(sltn.ParFESpace()->GetComm());
474 }
475 }
476 }
477}
478
479
480
482 const SparseMatrix &adv,
483 const Vector &Mlump)
484 : pfes(space), K(adv), D(adv), K_smap(), M_lumped(Mlump)
485{
486 // Assuming it is finalized.
487 const int *I = K.GetI(), *J = K.GetJ(), n = K.Size();
488 K_smap.SetSize(I[n]);
489 for (int row = 0, j = 0; row < n; row++)
490 {
491 for (int end = I[row+1]; j < end; j++)
492 {
493 int col = J[j];
494 // Find the offset, _j, of the (col,row) entry and store it in smap[j].
495 for (int _j = I[col], _end = I[col+1]; true; _j++)
496 {
497 MFEM_VERIFY(_j != _end, "Can't find the symmetric entry!");
498
499 if (J[_j] == row) { K_smap[j] = _j; break; }
500 }
501 }
502 }
503
505}
506
508 Vector &du) const
509{
510 ParGridFunction u_gf(&pfes);
511 u_gf = u;
513
514 const int s = du.Size();
515 for (int i = 0; i < s; i++)
516 {
517 du(i) = (du(i) + rhs(i)) / M_lumped(i);
518 }
519}
520
522{
523 const int *I = K.HostReadI(), *J = K.HostReadJ(), n = K.Size();
524
525 const real_t *K_data = K.HostReadData();
526
527 real_t *D_data = D.HostReadWriteData();
529
530 for (int i = 0, k = 0; i < n; i++)
531 {
532 real_t rowsum = 0.;
533 for (int end = I[i+1]; k < end; k++)
534 {
535 int j = J[k];
536 real_t kij = K_data[k];
537 real_t kji = K_data[K_smap[k]];
538 real_t dij = fmax(fmax(0.0,-kij),-kji);
539 D_data[k] = kij + dij;
540 D_data[K_smap[k]] = kji + dij;
541 if (i != j) { rowsum += dij; }
542 }
543 D(i,i) = K(i,i) - rowsum;
544 }
545}
546
548 Vector &du) const
549{
550 const int s = u.Size();
551 const int *I = D.HostReadI(), *J = D.HostReadJ();
552 const real_t *D_data = D.HostReadData();
553
554 u.ExchangeFaceNbrData();
555 const Vector &u_np = u.FaceNbrData();
556
557 for (int i = 0; i < s; i++)
558 {
559 du(i) = 0.0;
560 for (int k = I[i]; k < I[i + 1]; k++)
561 {
562 int j = J[k];
563 real_t u_j = (j < s) ? u(j) : u_np[j - s];
564 real_t d_ij = D_data[k];
565 du(i) += d_ij * u_j;
566 }
567 }
568}
569
570}
virtual void Mult(const Vector &x, Vector &dx) const
Perform the action of the operator: y = k = f(x, t), where k solves the algebraic equation F(x,...
enum mfem::AdvectionOper::AdvectionMode adv_mode
AdvectionOper(Array< bool > &zones, ParBilinearForm &Mbf, ParBilinearForm &Kbf, const Vector &rhs)
void SetSize(int nsize)
Change the logical size of the array, keep existing entries.
Definition array.hpp:697
virtual void Finalize(int skip_zeros=1)
Finalizes the matrix initialization if the AssemblyLevel is AssemblyLevel::LEGACY....
void AddDomainIntegrator(BilinearFormIntegrator *bfi)
Adds new Domain Integrator. Assumes ownership of bfi.
const SparseMatrix & SpMat() const
Returns a const reference to the sparse matrix: .
void AddInteriorFaceIntegrator(BilinearFormIntegrator *bfi)
Adds new interior Face Integrator. Assumes ownership of bfi.
Base class Coefficients that optionally depend on space and time. These are used by the BilinearFormI...
void Factor()
Factor the current DenseMatrix, *a.
void Mult(const real_t *x, real_t *y) const
Matrix vector multiplication with the inverse of dense matrix.
Data type dense matrix using column-major storage.
Definition densemat.hpp:24
void CalcLOSolution(const Vector &u, const Vector &rhs, Vector &du) const
void ApplyDiscreteUpwindMatrix(ParGridFunction &u, Vector &du) const
ParFiniteElementSpace & pfes
DiscreteUpwindLOSolver(ParFiniteElementSpace &space, const SparseMatrix &adv, const Vector &Mlump)
Class for domain integration .
Definition lininteg.hpp:109
AdvectionOper::AdvectionMode advection_mode
void ComputeLocalErrors(Coefficient &level_set, const ParGridFunction &exact, const ParGridFunction &xtrap, real_t &err_L1, real_t &err_L2, real_t &err_LI)
enum mfem::Extrapolator::XtrapType xtrap_type
void Extrapolate(Coefficient &level_set, const ParGridFunction &input, const real_t time_period, ParGridFunction &xtrap)
int GetNE() const
Returns number of elements in the mesh.
Definition fespace.hpp:740
int GetOrder(int i) const
Returns the polynomial degree of the i'th finite element.
Definition fespace.hpp:696
int GetVSize() const
Return the number of vector dofs, i.e. GetNDofs() x GetVDim().
Definition fespace.hpp:713
int GetDof() const
Returns the number of degrees of freedom in the finite element.
Definition fe_base.hpp:329
Coefficient defined by a GridFunction. This coefficient is mesh dependent.
virtual void ComputeElementL1Errors(Coefficient &exsol, Vector &error, const IntegrationRule *irs[]=NULL) const
Definition gridfunc.hpp:623
virtual void ComputeElementL2Errors(Coefficient &exsol, Vector &error, const IntegrationRule *irs[]=NULL) const
Definition gridfunc.hpp:629
virtual void ComputeElementMaxErrors(Coefficient &exsol, Vector &error, const IntegrationRule *irs[]=NULL) const
Definition gridfunc.hpp:635
void ProjectGridFunction(const GridFunction &src)
Project the src GridFunction to this GridFunction, both of which must be on the same mesh.
Arbitrary order H1-conforming (continuous) finite elements.
Definition fe_coll.hpp:260
HYPRE_Int Mult(HypreParVector &x, HypreParVector &y, real_t alpha=1.0, real_t beta=0.0) const
Computes y = alpha * A * x + beta * y.
Definition hypre.cpp:1815
Arbitrary order "L2-conforming" discontinuous finite elements.
Definition fe_coll.hpp:330
void AddDomainIntegrator(LinearFormIntegrator *lfi)
Adds new Domain Integrator. Assumes ownership of lfi.
int GetNE() const
Returns number of elements.
Definition mesh.hpp:1226
int Dimension() const
Dimension of the reference space used within the elements.
Definition mesh.hpp:1160
real_t GetElementSize(int i, int type=0)
Get the size of the i-th element relative to the perfect reference element.
Definition mesh.cpp:107
real_t GetElementVolume(int i)
Definition mesh.cpp:121
Abstract class for solving systems of ODEs: dx/dt = f(x,t)
Definition ode.hpp:24
virtual void Step(Vector &x, real_t &t, real_t &dt)=0
Perform a time step from time t [in] to time t [out] based on the requested step size dt [in].
Class for parallel bilinear form.
HypreParMatrix * ParallelAssemble()
Returns the matrix assembled on the true dofs, i.e. P^t A P.
void Assemble(int skip_zeros=1)
Assemble the local matrix.
ParFiniteElementSpace * ParFESpace() const
Return the parallel FE space associated with the ParBilinearForm.
void KeepNbrBlock(bool knb=true)
Abstract parallel finite element space.
Definition pfespace.hpp:29
MPI_Comm GetComm() const
Definition pfespace.hpp:273
void GetElementDofs(int i, Array< int > &dofs, DofTransformation &doftrans) const override
The same as GetElementDofs(), but with a user-allocated DofTransformation object. doftrans must be al...
Definition pfespace.cpp:468
ParMesh * GetParMesh() const
Definition pfespace.hpp:277
const FiniteElement * GetFE(int i) const override
Definition pfespace.cpp:534
Class for parallel grid function.
Definition pgridfunc.hpp:33
void ProjectDiscCoefficient(VectorCoefficient &coeff) override
Project a discontinuous vector coefficient as a grid function on a continuous finite element space....
ParFiniteElementSpace * ParFESpace() const
void ProjectCoefficient(Coefficient &coeff) override
Project coeff Coefficient to this GridFunction. The projection computation depends on the choice of t...
Class for parallel linear form.
void Assemble()
Assembles the ParLinearForm i.e. sums over all domain/bdr integrators.
Class for parallel meshes.
Definition pmesh.hpp:34
MPI_Comm GetComm() const
Definition pmesh.hpp:402
void Init(TimeDependentOperator &f_) override
Associate a TimeDependentOperator with the ODE solver.
Definition ode.cpp:39
void MarkElements(const ParGridFunction &ls_func, Array< int > &elem_marker)
Definition marking.cpp:17
Data type sparse matrix.
Definition sparsemat.hpp:51
const int * HostReadJ() const
void GetDiag(Vector &d) const
Returns the Diagonal of A.
void GetSubMatrix(const Array< int > &rows, const Array< int > &cols, DenseMatrix &subm) const
const real_t * HostReadData() const
real_t * HostReadWriteData()
int * GetJ()
Return the array J.
int * GetI()
Return the array I.
const int * HostReadI() const
int Size() const
For backward compatibility, define Size() to be synonym of Height().
Base abstract class for first order time dependent operators.
Definition operator.hpp:317
Vector coefficient defined by a vector GridFunction.
Vector data type.
Definition vector.hpp:80
void SetSubVector(const Array< int > &dofs, const real_t value)
Set the entries listed in dofs to the given value.
Definition vector.cpp:604
int Size() const
Returns the size of the vector.
Definition vector.hpp:218
void GetSubVector(const Array< int > &dofs, Vector &elemvect) const
Extract entries listed in dofs to the output Vector elemvect.
Definition vector.cpp:578
const real_t alpha
Definition ex15.cpp:369
int dim
Definition ex24.cpp:53
real_t b
Definition lissajous.cpp:42
string space
void VisualizeField(socketstream &sock, const char *vishost, int visport, GridFunction &gf, const char *title, int x, int y, int w, int h, const char *keys, bool vec)
int wsize
const int visport
real_t u(const Vector &xvec)
Definition lor_mms.hpp:22
float real_t
Definition config.hpp:43
const char vishost[]
RefCoord t[3]
RefCoord s[3]
Helper struct to convert a C++ type to an MPI type.