Documentation 6b54b78464
Loading...
Searching...
No Matches
CPyWrapperMatrixView.hpp File Reference

Simple matrix views to use with the python wrapper. More...

#include <string>
#include <utility>
#include <vector>
#include "../geometry/dual_grid/CVertex.hpp"
#include "../parallelization/mpi_structure.hpp"
#include "C2DContainer.hpp"

Go to the source code of this file.

Classes

class  CPyWrapperMatrixView
 This class wraps su2activematrix for the python wrapper matrix interface. It is generaly used to wrap access to solver variables defined for the entire volume. More...
 
class  CPyWrapperMarkerMatrixView
 This class wraps su2activematrix for the python wrapper matrix interface restricting it to the vertices of a given marker. More...
 
class  CPyWrapper3DMatrixView
 This class wraps C3DDoubleMatrix for the python wrapper matrix interface. It is generaly used to wrap access to solver gradients defined for the entire volume. More...
 

Macros

#define PY_WRAPPER_MATRIX_INTERFACE
 Python wrapper matrix interface The accessors in this macro provide a passive double interface to matrix of su2double. This can be extended to allow access to derivative information. Classes that use this macro encapsulate the access to the raw data (su2double) via the functions "Access(row, col) -> su2double&" (const and non-const versions). We use a macro because it is diffult to use modern C++ idioms (e.g. CRTP) with SWIG. In addition to "Access" classes must have member variables "rows_", "cols_", and "read_only_".
 

Detailed Description

Simple matrix views to use with the python wrapper.

Author
P. Gomes
Version
8.5.0 "Harrier"

SU2 Project Website: https://su2code.github.io

The SU2 Project is maintained by the SU2 Foundation (http://su2foundation.org)

Copyright 2012-2026, SU2 Contributors (cf. AUTHORS.md)

SU2 is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

SU2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with SU2. If not, see http://www.gnu.org/licenses/.

Macro Definition Documentation

◆ PY_WRAPPER_MATRIX_INTERFACE

#define PY_WRAPPER_MATRIX_INTERFACE
Value:
/*! \brief Returns the shape of the matrix. */ \
std::pair<unsigned long, unsigned long> Shape() const { return std::make_pair(rows_, cols_); } \
\
/*! \brief Returns whether the data is read-only [true] or if it can be modified [false]. */ \
bool IsReadOnly() const { return read_only_; } \
\
/*! \brief Gets the value for a (row, column) pair. */ \
passivedouble operator()(unsigned long row, unsigned long col) const { return Get(row, col); } \
\
/*! \brief Gets the values for a row of the matrix. */ \
std::vector<passivedouble> operator()(unsigned long row) const { return Get(row); } \
\
/*! \brief Gets the value for a (row, column) pair. */ \
passivedouble Get(unsigned long row, unsigned long col) const { return SU2_TYPE::GetValue(Access(row, col)); } \
\
/*! \brief Gets the values for a row of the matrix. */ \
std::vector<passivedouble> Get(unsigned long row) const { \
std::vector<passivedouble> vals(cols_); \
for (unsigned long j = 0; j < cols_; ++j) vals[j] = Get(row, j); \
return vals; \
} \
/*! \brief Sets the value for a (row, column) pair. This clears derivative information. */ \
void Set(unsigned long row, unsigned long col, passivedouble val) { Access(row, col) = val; } \
\
/*! \brief Sets the values for a row of the matrix. */ \
void Set(unsigned long row, std::vector<passivedouble> vals) { \
unsigned long j = 0; \
for (const auto& val : vals) Set(row, j++, val); \
}
double passivedouble
Definition code_config.hpp:129
passivedouble GetValue(const su2double &data)
Get the (primitive) value of the datatype (needs to be specialized for active types).
Definition datatype_structure.hpp:113

Python wrapper matrix interface The accessors in this macro provide a passive double interface to matrix of su2double. This can be extended to allow access to derivative information. Classes that use this macro encapsulate the access to the raw data (su2double) via the functions "Access(row, col) -> su2double&" (const and non-const versions). We use a macro because it is diffult to use modern C++ idioms (e.g. CRTP) with SWIG. In addition to "Access" classes must have member variables "rows_", "cols_", and "read_only_".