12 #include "../config/config.hpp"
48 int element_counter = 0;
52 for (
int i = 0; i < mesh.GetNE(); i++)
53 if (partitioning[i] == MyRank)
86 for (
int i = 0; i <
size; i++)
90 tv(tdof) = (*this)(i);
94 hypre_CSRMatrix *diag = hypre_ParCSRMatrixDiag(P);
95 int *I = hypre_CSRMatrixI(diag) + 1;
96 int *J = hypre_CSRMatrixJ(diag);
97 for (
int i = 0, j = 0; i <
size; i++)
99 tv(J[j++]) = (*this)(i);
164 MPI_Request *requests =
new MPI_Request[2*num_face_nbrs];
165 MPI_Request *send_requests = requests;
166 MPI_Request *recv_requests = requests + num_face_nbrs;
167 MPI_Status *statuses =
new MPI_Status[num_face_nbrs];
169 for (
int i = 0; i < send_data.Size(); i++)
170 send_data[i] =
data[send_ldof[i]];
172 for (
int fn = 0; fn < num_face_nbrs; fn++)
177 MPI_Isend(&send_data(send_offset[fn]),
178 send_offset[fn+1] - send_offset[fn],
179 MPI_DOUBLE, nbr_rank, tag, MyComm, &send_requests[fn]);
182 recv_offset[fn+1] - recv_offset[fn],
183 MPI_DOUBLE, nbr_rank, tag, MyComm, &recv_requests[fn]);
186 MPI_Waitall(num_face_nbrs, send_requests, statuses);
187 MPI_Waitall(num_face_nbrs, recv_requests, statuses);
205 int s = dofs.
Size()/fes_vdim;
226 return (DofVal * LocVec);
239 double loc_integral, glob_integral;
243 MPI_Allreduce(&loc_integral, &glob_integral, 1, MPI_DOUBLE, MPI_SUM,
246 (*this) *= (delta_c->
Scale() / glob_integral);
252 for (
int i = 0; i <
size; i++)
258 for (
int i = 0; i <
size; i++)
271 MyComm =
pfes -> GetComm();
273 MPI_Comm_size(MyComm, &NRanks);
274 MPI_Comm_rank(MyComm, &MyRank);
276 double **values =
new double*[NRanks];
277 int *nv =
new int[NRanks];
278 int *nvdofs =
new int[NRanks];
279 int *nedofs =
new int[NRanks];
280 int *nfdofs =
new int[NRanks];
281 int *nrdofs =
new int[NRanks];
284 nv[0] =
pfes -> GetVSize();
285 nvdofs[0] =
pfes -> GetNVDofs();
286 nedofs[0] =
pfes -> GetNEDofs();
287 nfdofs[0] =
pfes -> GetNFDofs();
294 for (p = 1; p < NRanks; p++)
296 MPI_Recv(&nv[p], 1, MPI_INT, p, 455, MyComm, &status);
297 MPI_Recv(&nvdofs[p], 1, MPI_INT, p, 456, MyComm, &status);
298 MPI_Recv(&nedofs[p], 1, MPI_INT, p, 457, MyComm, &status);
299 MPI_Recv(&nfdofs[p], 1, MPI_INT, p, 458, MyComm, &status);
300 values[p] =
new double[nv[p]];
301 MPI_Recv(values[p], nv[p], MPI_DOUBLE, p, 460, MyComm, &status);
304 int vdim =
pfes -> GetVDim();
306 for (p = 0; p < NRanks; p++)
307 nrdofs[p] = nv[p]/vdim - nvdofs[p] - nedofs[p] - nfdofs[p];
311 for (
int d = 0; d < vdim; d++)
313 for (p = 0; p < NRanks; p++)
314 for (i = 0; i < nvdofs[p]; i++)
315 out << *values[p]++ <<
'\n';
317 for (p = 0; p < NRanks; p++)
318 for (i = 0; i < nedofs[p]; i++)
319 out << *values[p]++ <<
'\n';
321 for (p = 0; p < NRanks; p++)
322 for (i = 0; i < nfdofs[p]; i++)
323 out << *values[p]++ <<
'\n';
325 for (p = 0; p < NRanks; p++)
326 for (i = 0; i < nrdofs[p]; i++)
327 out << *values[p]++ <<
'\n';
332 for (p = 0; p < NRanks; p++)
333 for (i = 0; i < nvdofs[p]; i++)
334 for (
int d = 0; d < vdim; d++)
335 out << *values[p]++ <<
'\n';
337 for (p = 0; p < NRanks; p++)
338 for (i = 0; i < nedofs[p]; i++)
339 for (
int d = 0; d < vdim; d++)
340 out << *values[p]++ <<
'\n';
342 for (p = 0; p < NRanks; p++)
343 for (i = 0; i < nfdofs[p]; i++)
344 for (
int d = 0; d < vdim; d++)
345 out << *values[p]++ <<
'\n';
347 for (p = 0; p < NRanks; p++)
348 for (i = 0; i < nrdofs[p]; i++)
349 for (
int d = 0; d < vdim; d++)
350 out << *values[p]++ <<
'\n';
353 for (p = 1; p < NRanks; p++)
361 MPI_Send(&nv[0], 1, MPI_INT, 0, 455, MyComm);
362 MPI_Send(&nvdofs[0], 1, MPI_INT, 0, 456, MyComm);
363 MPI_Send(&nedofs[0], 1, MPI_INT, 0, 457, MyComm);
364 MPI_Send(&nfdofs[0], 1, MPI_INT, 0, 458, MyComm);
365 MPI_Send(
data, nv[0], MPI_DOUBLE, 0, 460, MyComm);
380 if (p < numeric_limits<double>::infinity())
384 loc_norm = -pow(-loc_norm, p);
386 loc_norm = pow(loc_norm, p);
388 MPI_Allreduce(&loc_norm, &glob_norm, 1, MPI_DOUBLE, MPI_SUM, comm);
391 glob_norm = -pow(-glob_norm, 1.0/p);
393 glob_norm = pow(glob_norm, 1.0/p);
397 MPI_Allreduce(&loc_norm, &glob_norm, 1, MPI_DOUBLE, MPI_MAX, comm);
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)
void SetSize(int s)
Resizes the vector if the new size is different.
ParFiniteElementSpace * pfes
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.
Abstract parallel finite element space.
void ProjectCoefficient(Coefficient &coeff)
int Size_of_connections() const
int Mult(HypreParVector &x, HypreParVector &y, double alpha=1.0, double beta=0.0)
Computes y = alpha * A * x + beta * y.
void GetFaceNbrElementVDofs(int i, Array< int > &vdofs) const
virtual void Save(std::ostream &out) const
Save the GridFunction to an output stream.
const FiniteElement * GetFaceNbrFE(int i) const
void ExchangeFaceNbrData()
int MultTranspose(HypreParVector &x, HypreParVector &y, double alpha=1.0, double beta=0.0)
Computes y = alpha * A^t * x + beta * y.
Mesh * GetMesh() const
Returns the mesh.
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 GetLocalTDofNumber(int ldof)
int GetVDim() const
Returns vector dimension.
FiniteElementSpace * FESpace()
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.
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.
Base class Coefficient that may optionally depend on time.
FiniteElementSpace * fes
FE space on which grid function lives.
void SetSubVector(const Array< int > &dofs, const Vector &elemvect)
void GetElementVDofs(int i, Array< int > &dofs) const
Returns indexes of degrees of freedom in array dofs for i'th element.
FiniteElementCollection * fec
Used when the grid function is read from a file.
void Distribute(const Vector *tv)
static FiniteElementCollection * New(const char *name)
virtual const char * Name() const
Class for integration point with weight.
HypreParVector * ParallelAverage() const
Returns a new vector averaged on the true dofs.
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 ProjectCoefficient(Coefficient &coeff)
int GetFaceNbrVSize() const
void DofsToVDofs(Array< int > &dofs) const
const FiniteElementCollection * FEColl() const
Class for parallel meshes.
int GetFaceNbrRank(int fn) const