19 : _mesh(
std::move(meshToWatch)),
20 _txtWriter(exportFilename),
21 _isScalingOn(isScalingOn)
29 for (
size_t i = 0; i <
_mesh->data().size(); i++) {
53 "Watch-integral is configured with scaling option on; "
54 "however, mesh {} does not contain connectivity information. "
55 "Therefore, the integral will be calculated without scaling.",
68 const int dataDimensions = elem->getDimensions();
72 Eigen::VectorXd valueRecv = Eigen::VectorXd::Zero(dataDimensions);
74 integral = std::move(valueRecv);
77 if (dataDimensions == 1) {
79 }
else if (dataDimensions == 2) {
88 if (not
_mesh->edges().empty()) {
91 double surfaceAreaSum = 0.0;
93 surfaceArea = surfaceAreaSum;
101 double surfaceArea = 0.0;
102 double surfaceAreaSum = 0.0;
110 int dim = data->getDimensions();
111 const Eigen::VectorXd &values = data->values();
112 Eigen::VectorXd sum = Eigen::VectorXd::Zero(dim);
115 for (
const auto &vertex :
_mesh->vertices()) {
116 int offset = vertex.getID() * dim;
117 for (
int i = 0; i < dim; i++) {
118 sum[i] += values[offset + i];
130 double surfaceArea = 0.0;
131 if (
_mesh->getDimensions() == 3) {
132 for (
const auto &face :
_mesh->triangles()) {
133 surfaceArea += face.getArea();
136 for (
const auto &edge :
_mesh->edges()) {
137 surfaceArea += edge.getLength();
#define PRECICE_WARN_IF(condition,...)
#define PRECICE_ASSERT(...)
void initialize()
Adds surface area information based on mesh connectivity.
std::vector< mesh::PtrData > _dataToExport
Eigen::VectorXd calculateIntegral(const mesh::PtrData &data) const
WatchIntegral(mesh::PtrMesh meshToWatch, const std::string &exportFilename, bool isScalingOn)
Constructor.
void exportIntegralData(double time)
Writes one line with data of the integral over the mesh into the output file.
double calculateSurfaceArea() const
io::TXTTableWriter _txtWriter
DataType
Constants defining possible data types to be written.
void addData(const std::string &name, DataType type)
Adds a data entry to the table.
void writeData(const std::string &name, int value)
Writes a integral scalar data value associated to the entry name.
static int getSize()
Number of ranks. This includes ranks from both participants, e.g. minimal size is 2.
static bool isSecondary()
True if this process is running a secondary rank.
static void reduceSum(precice::span< const double > sendData, precice::span< double > rcvData)
Eigen::VectorXd integrateSurface(const PtrMesh &mesh, const Eigen::VectorXd &input)
Given the data and the mesh, this function returns the surface integral. Assumes no overlap exists fo...