43int main (
int argc,
char *argv[])
50 const char *mesh_file =
"../../data/rt-2d-q3.mesh";
52 bool visualization =
true;
57 args.
AddOption(&mesh_file,
"-m",
"--mesh",
"Mesh file to use");
58 args.
AddOption(&npt,
"-npt",
"--num-particles",
59 "Number of particles to initialize on global mesh "
61 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
63 "Enable or disable GLVis visualization.");
64 args.
AddOption(&visport,
"-p",
"--send-port",
"Socket for GLVis.");
84 ParMesh pmesh(MPI_COMM_WORLD, mesh);
87 std::mt19937 gen(rank);
88 std::uniform_real_distribution<real_t> real_dist;
92 for (
int d = 0; d < pset.
GetDim(); d++)
94 p.
Coords()[d] = pos_min[d] + real_dist(gen)*(pos_max[d] - pos_min[d]);
108 int num_removed = rm_idxs.
Size();
109 MPI_Allreduce(MPI_IN_PLACE, &num_removed, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
112 mfem::out << endl <<
"Removed " << num_removed <<
113 " particles that were not within the mesh" << endl << endl;
121 mfem::out <<
"Pre-Redistribute:" << endl;
134 pset, rank_vector, psize,
135 "Particle Owning Rank (Pre-Redistribute)",
136 0, 0, 400, 400, pset.
GetDim() == 2 ?
"Rjbcb" :
"cb");
158 "Particle Owning Rank (Post-Redistribute)",
159 410, 0, 400, 400, pset.
GetDim() == 2 ?
"Rjbcb" :
"cb");
170 int on_rank = 0, off_rank = 0;
171 for (
int i = 0; i < procs.
Size(); i++)
173 if (
static_cast<int>(procs[i]) == rank)
183 std::vector<int> all_on_rank(size), all_off_rank(size);
184 MPI_Gather(&on_rank, 1, MPI_INT, all_on_rank.data(), 1, MPI_INT, 0,
186 MPI_Gather(&off_rank, 1, MPI_INT, all_off_rank.data(), 1, MPI_INT, 0,
190 for (
int r = 0; r < size; r++)
193 << all_on_rank[r] <<
" within it, "
194 << all_off_rank[r] <<
" particles outside it\n";
203 for (
int i = 0; i < fields.
Size(); i++)
205 v[i] =
static_cast<real_t>(fields[i]);
int Size() const
Return the logical size of the array.
void DeleteAt(const Array< int > &indices)
Delete entries at indices, and resize.
FindPointsGSLIB can robustly evaluate a GridFunction on an arbitrary collection of points....
void FindPoints(const Vector &point_pos, int point_pos_ordering=Ordering::byNODES)
void Setup(Mesh &m, const double bb_t=0.1, const double newt_tol=1.0e-12, const int npt_max=256)
Array< unsigned int > GetPointsNotFoundIndices() const
Get array of indices of not-found points.
virtual const Array< unsigned int > & GetProc() const
Return MPI rank on which each point was found by FindPoints.
static void Init()
Initialize hypre by calling HYPRE_Init() and set default options. After calling Hypre::Init(),...
void EnsureNodes()
Make sure that the mesh has valid nodes, i.e. its geometry is described by a vector finite element gr...
void GetBoundingBox(Vector &min, Vector &max, int ref=2)
Returns the minimum and maximum corners of the mesh bounding box.
int Dimension() const
Dimension of the reference space used within the elements.
static int WorldRank()
Return the MPI rank in MPI_COMM_WORLD.
static int WorldSize()
Return the size of MPI_COMM_WORLD.
static void Init(int &argc, char **&argv, int required=default_thread_required, int *provided=nullptr)
Singleton creation with Mpi::Init(argc, argv).
void Parse()
Parse the command-line options. Note that this function expects all the options provided through the ...
void PrintUsage(std::ostream &out) const
Print the usage message.
void PrintOptions(std::ostream &out) const
Print the options.
void AddOption(bool *var, const char *enable_short_name, const char *enable_long_name, const char *disable_short_name, const char *disable_long_name, const char *description, bool required=false)
Add a boolean option and set 'var' to receive the value. Enable/disable tags are used to set the bool...
bool Good() const
Return true if the command line options were parsed successfully.
Class for parallel meshes.
ParticleSet initializes and manages data associated with particles.
void Redistribute(const Array< unsigned int > &rank_list)
Redistribute particle data to rank_list.
Particle GetParticleRef(int i)
Get Particle object whose members reference the actual data associated with particle i in this Partic...
ParticleVector & Coords()
Get a reference to the coordinates ParticleVector.
int GetDim() const
Get the spatial dimension.
int GetNParticles() const
Get the number of active particles currently held by this ParticleSet.
void RemoveParticles(const Array< int > &list)
Remove particle data specified by list of particle indices.
Ordering::Type GetOrdering() const
Get the ordering of data in the ParticleVector.
Container for data associated with a single particle.
Vector & Coords()
Get reference to particle coordinates Vector.
void VisualizeParticles(socketstream &sock, const char *vishost, int visport, const ParticleSet &pset, const Vector &scalar_field, real_t psize, const char *title, int x, int y, int w, int h, const char *keys)
Plot particles in ParticleSet pset, represented as quads/hexes of size psize and colored by scalar_fi...
OutStream out(std::cout)
Global stream used by the library for standard output. Initially it uses the same std::streambuf as s...
real_t Distance(const real_t *x, const real_t *y, const int n)
real_t p(const Vector &x, real_t t)
void PrintOnOffRankCounts(const Array< unsigned int > &procs)
Vector ArrayToVector(const Array< T > &fields)