12 #include "../config/config.hpp"
49 int element_counter = 0;
53 for (
int i = 0; i < mesh.GetNE(); i++)
54 if (partitioning[i] == MyRank)
174 MPI_Request *requests =
new MPI_Request[2*num_face_nbrs];
175 MPI_Request *send_requests = requests;
176 MPI_Request *recv_requests = requests + num_face_nbrs;
177 MPI_Status *statuses =
new MPI_Status[num_face_nbrs];
179 for (
int i = 0; i < send_data.Size(); i++)
181 send_data[i] =
data[send_ldof[i]];
184 for (
int fn = 0; fn < num_face_nbrs; fn++)
189 MPI_Isend(&send_data(send_offset[fn]),
190 send_offset[fn+1] - send_offset[fn],
191 MPI_DOUBLE, nbr_rank, tag, MyComm, &send_requests[fn]);
194 recv_offset[fn+1] - recv_offset[fn],
195 MPI_DOUBLE, nbr_rank, tag, MyComm, &recv_requests[fn]);
198 MPI_Waitall(num_face_nbrs, send_requests, statuses);
199 MPI_Waitall(num_face_nbrs, recv_requests, statuses);
217 int s = dofs.
Size()/fes_vdim;
238 return (DofVal * LocVec);
251 double loc_integral, glob_integral;
255 MPI_Allreduce(&loc_integral, &glob_integral, 1, MPI_DOUBLE, MPI_SUM,
258 (*this) *= (delta_c->
Scale() / glob_integral);
272 ldof_attr.
Copy(gdof_attr);
275 gcomm.
Bcast(gdof_attr);
281 if (gdof_attr[i] > ldof_attr[i])
295 gcomm.
Bcast(gdof_attr);
298 (*this)(i) /= gdof_attr[i];
308 for (
int i = 0; i <
size; i++)
315 for (
int i = 0; i <
size; i++)
329 MyComm =
pfes -> GetComm();
331 MPI_Comm_size(MyComm, &NRanks);
332 MPI_Comm_rank(MyComm, &MyRank);
334 double **values =
new double*[NRanks];
335 int *nv =
new int[NRanks];
336 int *nvdofs =
new int[NRanks];
337 int *nedofs =
new int[NRanks];
338 int *nfdofs =
new int[NRanks];
339 int *nrdofs =
new int[NRanks];
342 nv[0] =
pfes -> GetVSize();
343 nvdofs[0] =
pfes -> GetNVDofs();
344 nedofs[0] =
pfes -> GetNEDofs();
345 nfdofs[0] =
pfes -> GetNFDofs();
352 for (p = 1; p < NRanks; p++)
354 MPI_Recv(&nv[p], 1, MPI_INT, p, 455, MyComm, &status);
355 MPI_Recv(&nvdofs[p], 1, MPI_INT, p, 456, MyComm, &status);
356 MPI_Recv(&nedofs[p], 1, MPI_INT, p, 457, MyComm, &status);
357 MPI_Recv(&nfdofs[p], 1, MPI_INT, p, 458, MyComm, &status);
358 values[p] =
new double[nv[p]];
359 MPI_Recv(values[p], nv[p], MPI_DOUBLE, p, 460, MyComm, &status);
362 int vdim =
pfes -> GetVDim();
364 for (p = 0; p < NRanks; p++)
366 nrdofs[p] = nv[p]/vdim - nvdofs[p] - nedofs[p] - nfdofs[p];
371 for (
int d = 0; d < vdim; d++)
373 for (p = 0; p < NRanks; p++)
374 for (i = 0; i < nvdofs[p]; i++)
376 out << *values[p]++ <<
'\n';
379 for (p = 0; p < NRanks; p++)
380 for (i = 0; i < nedofs[p]; i++)
382 out << *values[p]++ <<
'\n';
385 for (p = 0; p < NRanks; p++)
386 for (i = 0; i < nfdofs[p]; i++)
388 out << *values[p]++ <<
'\n';
391 for (p = 0; p < NRanks; p++)
392 for (i = 0; i < nrdofs[p]; i++)
394 out << *values[p]++ <<
'\n';
400 for (p = 0; p < NRanks; p++)
401 for (i = 0; i < nvdofs[p]; i++)
402 for (
int d = 0; d < vdim; d++)
404 out << *values[p]++ <<
'\n';
407 for (p = 0; p < NRanks; p++)
408 for (i = 0; i < nedofs[p]; i++)
409 for (
int d = 0; d < vdim; d++)
411 out << *values[p]++ <<
'\n';
414 for (p = 0; p < NRanks; p++)
415 for (i = 0; i < nfdofs[p]; i++)
416 for (
int d = 0; d < vdim; d++)
418 out << *values[p]++ <<
'\n';
421 for (p = 0; p < NRanks; p++)
422 for (i = 0; i < nrdofs[p]; i++)
423 for (
int d = 0; d < vdim; d++)
425 out << *values[p]++ <<
'\n';
429 for (p = 1; p < NRanks; p++)
437 MPI_Send(&nv[0], 1, MPI_INT, 0, 455, MyComm);
438 MPI_Send(&nvdofs[0], 1, MPI_INT, 0, 456, MyComm);
439 MPI_Send(&nedofs[0], 1, MPI_INT, 0, 457, MyComm);
440 MPI_Send(&nfdofs[0], 1, MPI_INT, 0, 458, MyComm);
441 MPI_Send(
data, nv[0], MPI_DOUBLE, 0, 460, MyComm);
456 if (p < numeric_limits<double>::infinity())
461 loc_norm = -pow(-loc_norm, p);
465 loc_norm = pow(loc_norm, p);
468 MPI_Allreduce(&loc_norm, &glob_norm, 1, MPI_DOUBLE, MPI_SUM, comm);
472 glob_norm = -pow(-glob_norm, 1.0/p);
476 glob_norm = pow(glob_norm, 1.0/p);
481 MPI_Allreduce(&loc_norm, &glob_norm, 1, MPI_DOUBLE, MPI_MAX, comm);
512 MFEM_WARNING(
"Averaging on processor boundaries not implemented for "
517 for (
int i = 0; i < count.Size(); i++)
519 if (count[i] != 0) { flux(i) /= count[i]; }
540 int norm_p,
double solver_tol,
int solver_max_it)
550 for (
int i = 0; i < xfes->
GetNE(); i++)
557 *flux_fes.
GetFE(i), el_f,
false);
612 for (
int i = 0; i < xfes->
GetNE(); i++)
int GetNFaceNeighbors() const
int Size() const
Logical size of the array.
HypreParVector * NewTrueDofVector()
Class for grid function - Vector with associated FE space.
void SaveAsOne(std::ostream &out=std::cout)
Merge the local grid functions.
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.
HYPRE_Int MultTranspose(HypreParVector &x, HypreParVector &y, double alpha=1.0, double beta=0.0)
Computes y = alpha * A^t * x + beta * y.
void SetSize(int s)
Resizes the vector if the new size is different.
void GetElementVDofs(int i, Array< int > &vdofs) const
Returns indexes of degrees of freedom in array dofs for i'th element.
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
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.
void ProjectDiscCoefficient(VectorCoefficient &coeff)
Abstract parallel finite element space.
virtual const SparseMatrix * GetRestrictionMatrix()
Get the R matrix which restricts a local dof vector to true dof vector.
void ProjectCoefficient(Coefficient &coeff)
ParFiniteElementSpace * ParFESpace()
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)
void GetFaceNbrElementVDofs(int i, Array< int > &vdofs) const
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.
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.
Mesh * GetMesh() const
Returns the mesh.
void SetPrintLevel(int print_level)
void L2ZZErrorEstimator(BilinearFormIntegrator &flux_integrator, ParGridFunction &x, ParFiniteElementSpace &smooth_flux_fes, ParFiniteElementSpace &flux_fes, Vector &errors, int norm_p, double solver_tol, int solver_max_it)
virtual void CalcShape(const IntegrationPoint &ip, Vector &shape) const =0
virtual void GetElementDofs(int i, Array< int > &dofs) const
Returns indexes of degrees of freedom in array dofs for i'th element.
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)
HypreParMatrix * Dof_TrueDof_Matrix()
The true dof-to-dof interpolation matrix.
int GetOrdering() const
Return the ordering method.
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.
Abstract finite element space.
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)
void SetSubVector(const Array< int > &dofs, const Vector &elemvect)
FiniteElementCollection * fec
Used when the grid function is read from a file.
void Distribute(const Vector *tv)
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)
virtual const char * Name() const
Class for integration point with weight.
void Reduce(T *ldata, void(*Op)(OpData< T >))
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)
void ProjectCoefficient(Coefficient &coeff)
int GetFaceNbrVSize() const
for VectorFiniteElements (Nedelec, Raviart-Thomas)
void DofsToVDofs(Array< int > &dofs) const
const FiniteElementCollection * FEColl() const
Vector coefficient defined by a vector GridFunction.
Class for parallel grid function.
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.