12 #include "../config/config.hpp"
37 const int *partitioning)
53 int element_counter = 0;
55 const int glob_ne = glob_fes->
GetNE();
56 for (
int i = 0; i < glob_ne; i++)
58 if (partitioning[i] == MyRank)
91 MFEM_ASSERT(
pfes != NULL,
"not a ParFiniteElementSpace");
106 MFEM_ASSERT(
pfes != NULL,
"not a ParFiniteElementSpace");
121 MFEM_ASSERT(
pfes != NULL,
"not a ParFiniteElementSpace");
221 MPI_Request *requests =
new MPI_Request[2*num_face_nbrs];
222 MPI_Request *send_requests = requests;
223 MPI_Request *recv_requests = requests + num_face_nbrs;
224 MPI_Status *statuses =
new MPI_Status[num_face_nbrs];
226 for (
int i = 0; i < send_data.Size(); i++)
228 send_data[i] =
data[send_ldof[i]];
231 for (
int fn = 0; fn < num_face_nbrs; fn++)
236 MPI_Isend(&send_data(send_offset[fn]),
237 send_offset[fn+1] - send_offset[fn],
238 MPI_DOUBLE, nbr_rank, tag, MyComm, &send_requests[fn]);
241 recv_offset[fn+1] - recv_offset[fn],
242 MPI_DOUBLE, nbr_rank, tag, MyComm, &recv_requests[fn]);
245 MPI_Waitall(num_face_nbrs, send_requests, statuses);
246 MPI_Waitall(num_face_nbrs, recv_requests, statuses);
264 int s = dofs.
Size()/fes_vdim;
287 return (DofVal * LocVec);
300 double loc_integral, glob_integral;
304 MPI_Allreduce(&loc_integral, &glob_integral, 1, MPI_DOUBLE, MPI_SUM,
307 (*this) *= (delta_c->
Scale() / glob_integral);
321 ldof_attr.
Copy(gdof_attr);
324 gcomm.
Bcast(gdof_attr);
330 if (gdof_attr[i] > ldof_attr[i])
344 gcomm.
Bcast(gdof_attr);
347 (*this)(i) /= gdof_attr[i];
367 gcomm.
Bcast(zones_per_vdof);
389 gcomm.
Bcast(zones_per_vdof);
400 for (
int i = 0; i <
size; i++)
407 for (
int i = 0; i <
size; i++)
421 MyComm =
pfes -> GetComm();
423 MPI_Comm_size(MyComm, &NRanks);
424 MPI_Comm_rank(MyComm, &MyRank);
426 double **values =
new double*[NRanks];
427 int *nv =
new int[NRanks];
428 int *nvdofs =
new int[NRanks];
429 int *nedofs =
new int[NRanks];
430 int *nfdofs =
new int[NRanks];
431 int *nrdofs =
new int[NRanks];
434 nv[0] =
pfes -> GetVSize();
435 nvdofs[0] =
pfes -> GetNVDofs();
436 nedofs[0] =
pfes -> GetNEDofs();
437 nfdofs[0] =
pfes -> GetNFDofs();
444 for (p = 1; p < NRanks; p++)
446 MPI_Recv(&nv[p], 1, MPI_INT, p, 455, MyComm, &status);
447 MPI_Recv(&nvdofs[p], 1, MPI_INT, p, 456, MyComm, &status);
448 MPI_Recv(&nedofs[p], 1, MPI_INT, p, 457, MyComm, &status);
449 MPI_Recv(&nfdofs[p], 1, MPI_INT, p, 458, MyComm, &status);
450 values[p] =
new double[nv[p]];
451 MPI_Recv(values[p], nv[p], MPI_DOUBLE, p, 460, MyComm, &status);
454 int vdim =
pfes -> GetVDim();
456 for (p = 0; p < NRanks; p++)
458 nrdofs[p] = nv[p]/vdim - nvdofs[p] - nedofs[p] - nfdofs[p];
463 for (
int d = 0; d < vdim; d++)
465 for (p = 0; p < NRanks; p++)
466 for (i = 0; i < nvdofs[p]; i++)
468 out << *values[p]++ <<
'\n';
471 for (p = 0; p < NRanks; p++)
472 for (i = 0; i < nedofs[p]; i++)
474 out << *values[p]++ <<
'\n';
477 for (p = 0; p < NRanks; p++)
478 for (i = 0; i < nfdofs[p]; i++)
480 out << *values[p]++ <<
'\n';
483 for (p = 0; p < NRanks; p++)
484 for (i = 0; i < nrdofs[p]; i++)
486 out << *values[p]++ <<
'\n';
492 for (p = 0; p < NRanks; p++)
493 for (i = 0; i < nvdofs[p]; i++)
494 for (
int d = 0; d < vdim; d++)
496 out << *values[p]++ <<
'\n';
499 for (p = 0; p < NRanks; p++)
500 for (i = 0; i < nedofs[p]; i++)
501 for (
int d = 0; d < vdim; d++)
503 out << *values[p]++ <<
'\n';
506 for (p = 0; p < NRanks; p++)
507 for (i = 0; i < nfdofs[p]; i++)
508 for (
int d = 0; d < vdim; d++)
510 out << *values[p]++ <<
'\n';
513 for (p = 0; p < NRanks; p++)
514 for (i = 0; i < nrdofs[p]; i++)
515 for (
int d = 0; d < vdim; d++)
517 out << *values[p]++ <<
'\n';
521 for (p = 1; p < NRanks; p++)
530 MPI_Send(&nv[0], 1, MPI_INT, 0, 455, MyComm);
531 MPI_Send(&nvdofs[0], 1, MPI_INT, 0, 456, MyComm);
532 MPI_Send(&nedofs[0], 1, MPI_INT, 0, 457, MyComm);
533 MPI_Send(&nfdofs[0], 1, MPI_INT, 0, 458, MyComm);
534 MPI_Send(
data, nv[0], MPI_DOUBLE, 0, 460, MyComm);
554 loc_norm = -pow(-loc_norm, p);
558 loc_norm = pow(loc_norm, p);
561 MPI_Allreduce(&loc_norm, &glob_norm, 1, MPI_DOUBLE, MPI_SUM, comm);
565 glob_norm = -pow(-glob_norm, 1.0/p);
569 glob_norm = pow(glob_norm, 1.0/p);
574 MPI_Allreduce(&loc_norm, &glob_norm, 1, MPI_DOUBLE, MPI_MAX, comm);
587 MFEM_VERIFY(ffes,
"the flux FE space must be ParFiniteElementSpace");
604 MFEM_ABORT(
"Averaging on processor boundaries not implemented for "
606 "Use L2ZZErrorEstimator() instead of ZZErrorEstimator().");
610 for (
int i = 0; i < count.Size(); i++)
612 if (count[i] != 0) { flux(i) /= count[i]; }
633 int norm_p,
double solver_tol,
int solver_max_it)
643 for (
int i = 0; i < xfes->
GetNE(); i++)
650 *flux_fes.
GetFE(i), el_f,
false);
711 double total_error = 0.0;
713 for (
int i = 0; i < xfes->
GetNE(); i++)
716 total_error += pow(errors(i), norm_p);
720 MPI_Allreduce(&total_error, &glob_error, 1, MPI_DOUBLE, MPI_SUM,
723 return pow(glob_error, 1.0/norm_p);
728 #endif // MFEM_USE_MPI
Abstract class for Finite Elements.
int GetNFaceNeighbors() const
Ordering::Type GetOrdering() const
Return the ordering method.
int Size() const
Logical size of the array.
For scalar fields; preserves point values.
void SetSubVector(const Array< int > &dofs, const double value)
Set the entries listed in dofs to the given value.
void Reduce(T *ldata, void(*Op)(OpData< T >)) const
Reduce within each group where the master is the root.
int GetVSize() const
Return the number of vector dofs, i.e. GetNDofs() x GetVDim().
HypreParVector * NewTrueDofVector()
Class for grid function - Vector with associated FE space.
void Bcast(T *ldata, int layout) const
Broadcast within each group where the master is the root.
void ExchangeFaceNbrData()
HypreParVector * ParallelAssemble() const
Returns a new vector assembled on the true dofs.
void ProjectDeltaCoefficient(DeltaCoefficient &delta_coeff, double &integral)
HypreParVector * ParallelProject() const
Returns a new vector restricted to the true dofs.
virtual const Operator * GetProlongationMatrix() const
void SetSize(int s)
Resize the vector to size s.
void GetElementVDofs(int i, Array< int > &vdofs) const
Returns indexes of degrees of freedom in array dofs for i'th element.
double Scale()
Return the scale set by SetScale() multiplied by the time-dependent function specified by SetFunction...
void ProjectDiscCoefficient(VectorCoefficient &coeff, Array< int > &dof_attr)
ParFiniteElementSpace * pfes
void Copy(Array ©) const
Create a copy of the current array.
void GetSubVector(const Array< int > &dofs, Vector &elemvect) const
void SaveAsOne(std::ostream &out=mfem::out)
Merge the local grid functions.
Delta function coefficient.
int Size() const
Returns the size of the vector.
int GetNE() const
Returns number of elements.
virtual double GetValue(int i, const IntegrationPoint &ip, int vdim=1) const
virtual void Save(std::ostream &out) const
void DivideByGroupSize(double *vec)
Scale a vector of true dofs.
virtual void Mult(const Vector &x, Vector &y) const =0
Operator application: y=A(x).
virtual void ProjectDiscCoefficient(VectorCoefficient &coeff)
Project a discontinuous vector coefficient as a grid function on a continuous finite element space...
virtual void SetSpace(FiniteElementSpace *f)
Associate a new FiniteElementSpace with the ParGridFunction.
Abstract parallel finite element space.
virtual void ProjectCoefficient(Coefficient &coeff)
void ComputeMeans(AvgType type, Array< int > &zones_per_vdof)
double * GetData() const
Return a pointer to the beginning of the Vector data.
HYPRE_Int Mult(HypreParVector &x, HypreParVector &y, double alpha=1.0, double beta=0.0)
Computes y = alpha * A * x + beta * y.
int Size_of_connections() const
void SetPrintLevel(int print_lvl)
virtual void MultTranspose(const Vector &x, Vector &y) const
Action of the transpose operator: y=A^t(x). The default behavior in class Operator is to generate an ...
void GetFaceNbrElementVDofs(int i, Array< int > &vdofs) const
virtual void MakeRef(FiniteElementSpace *f, double *v)
Make the ParGridFunction reference external data on a new FiniteElementSpace.
virtual void Save(std::ostream &out) const
Save the GridFunction to an output stream.
int GetNE() const
Returns number of elements in the mesh.
The BoomerAMG solver in hypre.
Communicator performing operations within groups defined by a GroupTopology with arbitrary-size data ...
void SumFluxAndCount(BilinearFormIntegrator &blfi, GridFunction &flux, Array< int > &counts, int wcoef, int subdomain)
const FiniteElement * GetFaceNbrFE(int i) const
void ExchangeFaceNbrData()
static void Sum(OpData< T >)
Reduce operation Sum, instantiated for int and double.
virtual void Update()
Transform by the Space UpdateMatrix (e.g., on Mesh change).
void SetPrintLevel(int print_level)
virtual void CalcShape(const IntegrationPoint &ip, Vector &shape) const =0
Evaluate the values of all shape functions of a scalar finite element in reference space at the given...
HypreParMatrix * Dof_TrueDof_Matrix() const
The true dof-to-dof interpolation matrix.
virtual void GetElementDofs(int i, Array< int > &dofs) const
Returns indexes of degrees of freedom in array dofs for i'th element.
void AccumulateAndCountZones(Coefficient &coeff, AvgType type, Array< int > &zones_per_vdof)
Accumulates (depending on type) the values of coeff at all shared vdofs and counts in how many zones ...
virtual void MakeRef(FiniteElementSpace *f, double *v)
Make the GridFunction reference external data on a new FiniteElementSpace.
int GetVDim() const
Returns vector dimension.
FiniteElementSpace * FESpace()
void AddElementVector(const Array< int > &dofs, const Vector &elemvect)
Add (element) subvector to the vector.
void SetMaxIter(int max_iter)
Wrapper for hypre's parallel vector class.
ElementTransformation * GetElementTransformation(int i) const
Returns ElementTransformation for the i-th element.
double GlobalLpNorm(const double p, double loc_norm, MPI_Comm comm)
Compute a global Lp norm from the local Lp norms computed by each processor.
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
virtual void Mult(const Vector &x, Vector &y) const
Matrix vector multiplication.
Base class Coefficient that may optionally depend on time.
FiniteElementSpace * fes
FE space on which grid function lives.
static void Max(OpData< T >)
Reduce operation Max, instantiated for int and double.
GroupCommunicator & GroupComm()
Return a reference to the internal GroupCommunicator (on VDofs)
FiniteElementCollection * fec
Used when the grid function is read from a file.
double L2ZZErrorEstimator(BilinearFormIntegrator &flux_integrator, const ParGridFunction &x, ParFiniteElementSpace &smooth_flux_fes, ParFiniteElementSpace &flux_fes, Vector &errors, int norm_p, double solver_tol, int solver_max_it)
void Distribute(const Vector *tv)
virtual void Update()
Transform by the Space UpdateMatrix (e.g., on Mesh change).
double ComputeElementLpDistance(double p, int i, GridFunction &gf1, GridFunction &gf2)
Compute the Lp distance between two grid functions on the given element.
bool Nonconforming() const
static FiniteElementCollection * New(const char *name)
Factory method: return a newly allocated FiniteElementCollection according to the given name...
virtual const char * Name() const
Class for integration point with weight.
virtual const SparseMatrix * GetRestrictionMatrix() const
Get the R matrix which restricts a local dof vector to true dof vector.
HypreParVector * ParallelAverage() const
Returns a new vector averaged on the true dofs.
void SetPreconditioner(HypreSolver &precond)
Set the hypre solver to be used as a preconditioner.
void Destroy()
Destroy a vector.
const FiniteElement * GetFE(int i) const
Returns pointer to the FiniteElement associated with i'th element.
HypreParVector * GetTrueDofs() const
Returns the true dofs in a new HypreParVector.
void AddDistribute(double a, const Vector *tv)
double infinity()
Define a shortcut for std::numeric_limits<double>::infinity()
virtual void ProjectCoefficient(Coefficient &coeff)
virtual void SetSpace(FiniteElementSpace *f)
Associate a new FiniteElementSpace with the GridFunction.
int GetFaceNbrVSize() const
for VectorFiniteElements (Nedelec, Raviart-Thomas)
const FiniteElementCollection * FEColl() const
Vector coefficient defined by a vector GridFunction.
Class for parallel grid function.
OutStream out(std::cout)
Global stream used by the library for standard output. Initially it uses the same std::streambuf as s...
Wrapper for hypre's ParCSR matrix class.
virtual void Mult(const HypreParVector &b, HypreParVector &x) const
Solve Ax=b with hypre's PCG.
Class for parallel meshes.
int GetFaceNbrRank(int fn) const
Integrator for (Q u, v) for VectorFiniteElements.
virtual void ComputeFlux(BilinearFormIntegrator &blfi, GridFunction &flux, int wcoef=1, int subdomain=-1)
void ParallelProject(Vector &tv) const
Returns the vector restricted to the true dofs.
ParFiniteElementSpace * ParFESpace() const
void DofsToVDofs(Array< int > &dofs, int ndofs=-1) const