34 for (
int o = 0; o < 3; o++)
47 beta_k[o][0] = (1.0 + 2.0 * rho1) / (1.0 + rho1);
48 beta_k[o][1] = -(1.0 + rho1);
49 beta_k[o][2] = pow(rho1, 2.0) / (1.0 + rho1);
58 beta_k[o][0] = 1.0 + rho1 / (1.0 + rho1)
59 + (rho2 * rho1) / (1.0 + rho2 * (1 + rho1));
60 beta_k[o][1] = -1.0 - rho1 -
61 (rho2 * rho1 * (1.0 + rho1)) / (1.0 + rho2);
62 beta_k[o][2] = pow(rho1, 2.0) * (rho2 + 1.0 / (1.0 + rho1));
63 beta_k[o][3] = -(pow(rho2, 3.0) * pow(rho1, 2.0) * (1.0 + rho1))
64 / ((1.0 + rho2) * (1.0 + rho2 + rho2 * rho1));
67 (1.0 + rho2 * (1.0 + rho1))) / (1.0 + rho2);
68 alpha_k[o][1] = -rho1 * (1.0 + rho2 * (1.0 + rho1));
69 alpha_k[o][2] = (pow(rho2, 2.0) * rho1 * (1.0 + rho1)) / (1.0 + rho2);
78 int order_idx =
Order()[
p] - 1;
89 for (
int j = 1; j <= 3; j++)
91 w_n_ext +=
alpha[j-1]*
W(j)(
p, 0);
96 { -zeta*dt*w_n_ext, beta[0]+dt*
kappa}});
100 for (
int j = 1; j <= 3; j++)
126 for (
int j = 1; j <= 3; j++)
137 bool inv_normal,
Vector &normal)
145 normal[1] = -diff[0];
149 normal[0] = -diff[1];
152 normal /= normal.
Norml2();
162 real_t denom = (s1_end[0]-s1_start[0])*(s2_start[1] - s2_end[1]) -
163 (s1_end[1]-s1_start[1])*(s2_start[0] - s2_end[0]);
174 real_t t1 = ( (s2_start[0] - s1_start[0])*(s2_start[1]-s2_end[1]) -
175 (s2_start[1] - s1_start[1])*(s2_start[0]-s2_end[0]) ) / denom;
176 real_t t2 = ( (s1_end[0] - s1_start[0])*(s2_start[1] - s1_start[1]) -
177 (s1_end[1] - s1_start[1])*(s2_start[0] - s1_start[0]))/ denom;
180 if ((0_r <= t1 && t1 <= 1_r) && (0_r <= t2 && t2 <= 1_r))
205 Vector p_xn(2), p_xnm1(2), p_xdiff(2), x_int(2), p_vn(2), p_vdiff(2);
214 p_xnm1, p_xn, x_int))
221 if (p_xdiff*normal > 0)
226 real_t dt_c = p_xnm1.DistanceTo(x_int)/p_vn.Norml2();
230 add(p_vn, -(1+bc.
e)*(p_vn*normal), normal, p_vn);
245 Vector inlet_normal(2), outlet_normal(2);
254 Vector inlet_tan(2), outlet_tan(2);
257 inlet_tan /= inlet_length;
260 outlet_tan /= outlet_length;
263 Vector p_xn(2), p_xnm1(2), x_int(2), p_xc(2), p_x_int_diff(2);
280 p_x_int_diff -= x_int;
281 real_t normal_dist =
abs(p_x_int_diff*outlet_normal);
282 add(p_xc, normal_dist, inlet_normal, p_xc);
285 real_t tan_dist =
abs(p_x_int_diff*outlet_tan);
286 add(p_xc, tan_dist, inlet_tan, p_xc);
305 using T = std::decay_t<
decltype(bc)>;
306 if constexpr(std::is_same_v<T, ReflectionBC_2D>)
310 else if constexpr(std::is_same_v<T, RecirculationBC_2D>)
320 : fluid_particles(comm, num_particles, m.SpaceDimension()),
321 inactive_fluid_particles(comm, 0, m.SpaceDimension()),
325 for (
int o = 0; o < 3; o++)
347 for (
int i = 0; i <
N_HIST; i++)
373 for (
int i =
N_HIST-1; i > 0; i--)
375 U(i) = std::move(
U(i-1));
376 V(i) = std::move(
V(i-1));
377 W(i) = std::move(
W(i-1));
378 X(i) = std::move(
X(i-1));
392 int &order =
Order()[i];
402 MFEM_ABORT(
"3D particles not yet implemented.");
447 for (
int i = 0; i < lost_idxs.
Size(); i++)
int Size() const
Return the logical size of the array.
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.
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)
virtual void Interpolate(const GridFunction &field_in, Vector &field_out)
Array< unsigned int > GetPointsNotFoundIndices() const
Get array of indices of not-found points.
Ordering::Type GetOrdering() const
Return the ordering method.
static void Reorder(Vector &v, int vdim, Type in_ord, Type out_ord)
Reorder Vector v from its current ordering in_ord to out_ord.
Class for parallel grid function.
ParFiniteElementSpace * ParFESpace() const
ParticleVector & Coords()
Get a reference to the coordinates ParticleVector.
int AddTag(const char *tag_name=nullptr)
Add a tag to the ParticleSet.
ParticleVector & Field(int f)
Get a reference to field f 's ParticleVector.
int GetDim() const
Get the spatial dimension.
int GetNParticles() const
Get the number of active particles currently held by this ParticleSet.
Array< int > & Tag(int t)
Get a reference to tag t 's Array<int>.
int AddField(int vdim, Ordering::Type field_ordering=Ordering::byVDIM, const char *field_name=nullptr)
Add a field to the ParticleSet.
void Reserve(int res)
Reserve memory for res particles.
void RemoveParticles(const Array< int > &list)
Remove particle data specified by list of particle indices.
void AddParticles(const Array< IDType > &new_ids, Array< int > *new_indices=nullptr)
Add particles with global identifiers new_ids and optionally get the local indices of new particles i...
int AddNamedField(int vdim, const char *field_name, Ordering::Type field_ordering=Ordering::byVDIM)
Add a field to the ParticleSet.
void SetValues(int i, const Vector &nvals)
Set particle i 's data to nvals .
void GetValues(int i, Vector &nvals) const
Get a copy of particle i 's data.
void GetValuesRef(int i, Vector &nref)
For GetOrdering == Ordering::byVDIM, set nref to refer to particle i 's data.
real_t Norml2() const
Returns the l2 norm of the vector.
void SetSize(int s)
Resize the vector to size s.
real_t DistanceTo(const real_t *p) const
Compute the Euclidean distance to another vector.
Array< real_t > dthist
Timestep history.
void SetTimeIntegrationCoefficients()
Update beta_k and alpha_k using current dthist.
ParticleVector & V(int nm=0)
Get reference to the particle velocity ParticleVector at time n - nm .
ParticleSet inactive_fluid_particles
ParticleVector & W(int nm=0)
Get reference to the fluid vorticity-interpolated ParticleVector at time n - nm .
static constexpr int N_HIST
Number of timesteps to store (includes current)
struct mfem::navier::NavierParticles::FluidParticleIndices fp_idx
void InterpolateUW(const ParGridFunction &u_gf, const ParGridFunction &w_gf)
Interpolate fluid velocity and vorticity onto current particles' location.
Array< int > & Order()
Get reference to the order Array<int>.
ParticleVector & U(int nm=0)
Get reference to the fluid velocity-interpolated ParticleVector at time n - nm .
void ParticleStep2D(const real_t &dt, int p)
2D particle step for particle at index p
static bool Get2DSegmentIntersection(const Vector &s1_start, const Vector &s1_end, const Vector &s2_start, const Vector &s2_end, Vector &x_int, real_t *t1_ptr=nullptr, real_t *t2_ptr=nullptr)
Given two 2D segments, get the intersection point if it exists.
ParticleVector & X(int nm=0)
Get reference to the position ParticleVector at time n - nm .
void ApplyBCs()
Apply all BCs in bcs.
std::variant< ReflectionBC_2D, RecirculationBC_2D > BCVariant
ParticleVector & Gamma()
Get reference to the γ ParticleVector.
void DeactivateLostParticles(bool findpts)
Move any particles that have left the domain to the inactive ParticleSet.
void Step(const real_t dt, const ParGridFunction &u_gf, const ParGridFunction &w_gf)
Step the particles in time.
void Apply2DReflectionBC(const ReflectionBC_2D &bc)
Apply 2D reflection BCs to update particle positions and velocities.
std::array< Array< real_t >, 3 > beta_k
BDFk coefficients, k=1,2,3.
ParticleVector & Kappa()
Get reference to the κ ParticleVector.
void Apply2DRecirculationBC(const RecirculationBC_2D &bc)
Apply 2D recirculation BCs.
NavierParticles(MPI_Comm comm, int num_particles, Mesh &m)
Initialize NavierParticles with num_particles using fluid mesh m .
static void Get2DNormal(const Vector &p1, const Vector &p2, bool inv_normal, Vector &normal)
Given two 2D points, get the unit normal to the line connecting them.
ParticleSet fluid_particles
Active fluid particle set.
std::array< Array< real_t >, 3 > alpha_k
EXTk coefficients, k=1,2,3.
ParticleVector & Zeta()
Get reference to the ζ ParticleVector.
std::vector< BCVariant > bcs
std::vector of all boundary condition structs
void add(const Vector &v1, const Vector &v2, Vector &v)
real_t p(const Vector &x, real_t t)
MFEM_HOST_DEVICE real_t abs(const Complex &z)
struct mfem::navier::NavierParticles::FluidParticleIndices::FieldIndices field
struct mfem::navier::NavierParticles::FluidParticleIndices::TagIndices tag
2D recirculation boundary condition struct
const bool invert_outlet_normal
const bool invert_inlet_normal
const Vector outlet_start
2D wall reflection boundary condition struct