65 m_obs_pressure->observable = std::make_unique<Observable_stat>(9ul, 0ul, 0);
72 obs_pressure.reset(
static_cast<std::size_t
>(
bonded_ias->get_next_key()),
81 auto const volume =
box_geo->volume();
90 [](
auto &a,
auto const &b) { a += b; });
91 std::ranges::copy(
Utils::flatten(kinetic), obs_pressure.kinetic_lin.begin());
93 auto const coulomb_force_kernel =
coulomb.pair_force_kernel();
94 auto const coulomb_pressure_kernel =
coulomb.pair_pressure_kernel();
95 auto const dipoles_pressure_kernel =
dipoles.pair_pressure_kernel();
99 auto const make_verlet_criterion = [&] {
110 static_cast<std::size_t
>(
bonded_ias->get_next_key()),
111 std::size_t(
nonbonded_ias->get_max_seen_particle_type() + 1)};
113 using exec = Kokkos::DefaultHostExecutionSpace;
114 if (local_pressure.extent(1) != layout.
total * 9ul) {
115 Kokkos::realloc(Kokkos::WithoutInitializing, local_pressure,
116 exec{}.concurrency(), layout.
total * 9ul);
120 auto const &unique_particles =
cell_structure->get_unique_particles();
121 auto const n_particles = unique_particles.size();
122 Kokkos::View<int *, Kokkos::LayoutRight, exec> mol_id(
"mol_id", n_particles);
123 for (std::size_t i = 0; i < n_particles; ++i) {
124 mol_id(i) = unique_particles[i]->mol_id();
131 get_ptr(coulomb_pressure_kernel),
132 get_ptr(dipoles_pressure_kernel),
149 bonds_p_data, bs.pair_list, bs.pair_ids,
get_ptr(coulomb_force_kernel)};
157 bonded_ias->maximal_cutoff(), make_verlet_criterion,
163#ifdef ESPRESSO_ELECTROSTATICS
165 auto const coulomb_pressure =
coulomb.calc_pressure_long_range();
166 std::ranges::copy(coulomb_pressure, obs_pressure.coulomb.begin() + 9u);
168#ifdef ESPRESSO_DIPOLES
170 auto const dipoles_pressure =
dipoles.calc_pressure_long_range();
171 std::ranges::copy(dipoles_pressure, obs_pressure.dipolar.begin() + 9u);
174#ifdef ESPRESSO_VIRTUAL_SITES_RELATIVE
175 if (!obs_pressure.virtual_sites.empty()) {
178 obs_pressure.virtual_sites.begin());
182#ifdef ESPRESSO_BOND_CONSTRAINT
189 auto const &rigid_bond_virial =
bonded_ias->rigid_bond_virial;
190 for (std::size_t bond_id = 0; bond_id < rigid_bond_virial.size();
192 auto const stress = rigid_bond_virial[bond_id] / sq_dt;
193 auto dest = obs_pressure.bonded_contribution(
static_cast<int>(bond_id));
194 for (std::size_t k = 0; k < 9u; ++k)
195 dest[k] += stress[k];
200 obs_pressure.rescale(volume);
202 obs_pressure.mpi_reduce();
ESPRESSO_ATTR_ALWAYS_INLINE void kokkos_deep_copy(auto const &exec_space, auto const &view, auto const &value)
Wrapper for Kokkos::deep_copy that skips fork/join when the number of threads is 1.
ResultType reduce_over_local_particles(CellStructure const &cs, std::invocable< ResultType &, Particle const & > auto add_partial, std::invocable< ResultType &, ResultType const & > auto reduce_op)
Run a reduction over all particles.
static void reduce_cabana_pressure(Kokkos::View< double **, Kokkos::LayoutRight, Kokkos::HostSpace > const &local_pressure, PressureBinLayout const &layout, Observable_stat &obs, BondedInteractionsMap const &bonded_ias, int n_types)
void cabana_short_range(auto const &pair_bonds_kernel, auto const &angle_bonds_kernel, auto const &dihedral_bonds_kernel, auto const &nonbonded_kernel, CellStructure &cell_structure, double pair_cutoff, double bond_cutoff, auto const &make_verlet_criterion, auto const integ_switch, ShortRangeVerletPairLoop const &verlet_pair_loop={})
Struct holding all information for one particle.