Loading [MathJax]/extensions/TeX/AMSmath.js
ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages Concepts
LBFluidPressureTensor.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2010-2022 The ESPResSo project
3 *
4 * This file is part of ESPResSo.
5 *
6 * ESPResSo is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * ESPResSo is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19#ifndef OBSERVABLES_LB_FLUID_STRESS_HPP
20#define OBSERVABLES_LB_FLUID_STRESS_HPP
21
22#include "Observable.hpp"
23#include "system/System.hpp"
24
25#include <utils/math/sqr.hpp>
27
28#include <boost/mpi/collectives/reduce.hpp>
29
30#include <cstddef>
31#include <functional>
32#include <vector>
33
34namespace Observables {
36public:
37 std::vector<std::size_t> shape() const override { return {3, 3}; }
38 std::vector<double>
39 operator()(boost::mpi::communicator const &comm) const override {
40 auto const &lb = System::get_system().lb;
41 auto const pressure_conv = 1. / (lb.get_agrid() * Utils::sqr(lb.get_tau()));
42 auto const local_tensor = lb.get_pressure_tensor() * pressure_conv;
43 std::remove_const_t<decltype(local_tensor)> tensor;
44 boost::mpi::reduce(comm, local_tensor, tensor, std::plus<>(), 0);
45 return tensor.as_vector();
46 }
47};
48
49} // Namespace Observables
50
51#endif
std::vector< double > operator()(boost::mpi::communicator const &comm) const override
std::vector< std::size_t > shape() const override
Base class for observables.
System & get_system()
DEVICE_QUALIFIER constexpr T sqr(T x)
Calculates the SQuaRe of x.
Definition sqr.hpp:28
Utils::VectorXd< 9 > get_pressure_tensor() const