[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Getfem-commits] (no subject)
From: |
Konstantinos Poulios |
Subject: |
[Getfem-commits] (no subject) |
Date: |
Tue, 23 Jan 2024 05:31:40 -0500 (EST) |
branch: add-umfpack-interface
commit c33dc738a672c98c19dd3dc45bf80dc96bf3d583
Author: Konstantinos Poulios <logari81@gmail.com>
AuthorDate: Tue Jan 23 11:28:31 2024 +0100
Minor code maintenance changes
---
src/gmm/gmm_matrix.h | 68 +++++++++++++++++++++++++-------------------------
tests/wave_equation.cc | 48 +++++++++++++++++------------------
2 files changed, 58 insertions(+), 58 deletions(-)
diff --git a/src/gmm/gmm_matrix.h b/src/gmm/gmm_matrix.h
index 60b29178..db375938 100644
--- a/src/gmm/gmm_matrix.h
+++ b/src/gmm/gmm_matrix.h
@@ -140,7 +140,7 @@ namespace gmm
typedef typename linalg_traits<V>::value_type value_type;
row_matrix(size_type r, size_type c) : li(r, V(c)), nc(c) {}
- row_matrix(void) : nc(0) {}
+ row_matrix() : nc(0) {}
reference operator ()(size_type l, size_type c)
{ return li[l][c]; }
value_type operator ()(size_type l, size_type c) const
@@ -149,13 +149,13 @@ namespace gmm
void clear_mat();
void resize(size_type m, size_type n);
- typename std::vector<V>::iterator begin(void)
+ typename std::vector<V>::iterator begin()
{ return li.begin(); }
- typename std::vector<V>::iterator end(void)
+ typename std::vector<V>::iterator end()
{ return li.end(); }
- typename std::vector<V>::const_iterator begin(void) const
+ typename std::vector<V>::const_iterator begin() const
{ return li.begin(); }
- typename std::vector<V>::const_iterator end(void) const
+ typename std::vector<V>::const_iterator end() const
{ return li.end(); }
@@ -164,8 +164,8 @@ namespace gmm
V& operator[](size_type i) { return li[i]; }
const V& operator[](size_type i) const { return li[i]; }
- inline size_type nrows(void) const { return li.size(); }
- inline size_type ncols(void) const { return nc; }
+ inline size_type nrows() const { return li.size(); }
+ inline size_type ncols() const { return nc; }
void swap(row_matrix<V> &m) { std::swap(li, m.li); std::swap(nc, m.nc); }
void swap_row(size_type i, size_type j) { std::swap(li[i], li[j]); }
@@ -248,7 +248,7 @@ namespace gmm
typedef typename linalg_traits<V>::value_type value_type;
col_matrix(size_type r, size_type c) : li(c, V(r)), nr(r) { }
- col_matrix(void) : nr(0) {}
+ col_matrix() : nr(0) {}
reference operator ()(size_type l, size_type c)
{ return li[c][l]; }
value_type operator ()(size_type l, size_type c) const
@@ -262,17 +262,17 @@ namespace gmm
V& operator[](size_type i) { return li[i]; }
const V& operator[](size_type i) const { return li[i]; }
- typename std::vector<V>::iterator begin(void)
+ typename std::vector<V>::iterator begin()
{ return li.begin(); }
- typename std::vector<V>::iterator end(void)
+ typename std::vector<V>::iterator end()
{ return li.end(); }
- typename std::vector<V>::const_iterator begin(void) const
+ typename std::vector<V>::const_iterator begin() const
{ return li.begin(); }
- typename std::vector<V>::const_iterator end(void) const
+ typename std::vector<V>::const_iterator end() const
{ return li.end(); }
- inline size_type ncols(void) const { return li.size(); }
- inline size_type nrows(void) const { return nr; }
+ inline size_type ncols() const { return li.size(); }
+ inline size_type nrows() const { return nr; }
void swap(col_matrix<V> &m) { std::swap(li, m.li); std::swap(nr, m.nr); }
void swap_col(size_type i, size_type j) { std::swap(li[i], li[j]); }
@@ -365,22 +365,22 @@ namespace gmm
return *(this->begin() + c*nbl+l);
}
- std::vector<T> &as_vector(void) { return *this; }
- const std::vector<T> &as_vector(void) const { return *this; }
+ std::vector<T> &as_vector() { return *this; }
+ const std::vector<T> &as_vector() const { return *this; }
void resize(size_type, size_type);
void base_resize(size_type, size_type);
void reshape(size_type, size_type);
void fill(T a, T b = T(0));
- inline size_type nrows(void) const { return nbl; }
- inline size_type ncols(void) const { return nbc; }
+ inline size_type nrows() const { return nbl; }
+ inline size_type ncols() const { return nbc; }
void swap(dense_matrix<T> &m)
{ std::vector<T>::swap(m); std::swap(nbc, m.nbc); std::swap(nbl, m.nbl); }
dense_matrix(size_type l, size_type c)
: std::vector<T>(c*l), nbc(c), nbl(l) {}
- dense_matrix(void) { nbl = nbc = 0; }
+ dense_matrix() { nbl = nbc = 0; }
};
template<typename T> void dense_matrix<T>::reshape(size_type m,size_type n) {
@@ -523,11 +523,11 @@ namespace gmm
void init_with_identity(size_type n);
- csc_matrix(void) : nc(0), nr(0) {}
+ csc_matrix() : nc(0), nr(0) {}
csc_matrix(size_type nnr, size_type nnc);
- size_type nrows(void) const { return nr; }
- size_type ncols(void) const { return nc; }
+ size_type nrows() const { return nr; }
+ size_type ncols() const { return nc; }
void swap(csc_matrix<T, IND_TYPE, shift> &m) {
std::swap(pr, m.pr);
std::swap(ir, m.ir); std::swap(jc, m.jc);
@@ -670,11 +670,11 @@ namespace gmm
template <typename Matrix> void init_with(const Matrix &A);
void init_with_identity(size_type n);
- csr_matrix(void) : nc(0), nr(0) {}
+ csr_matrix() : nc(0), nr(0) {}
csr_matrix(size_type nnr, size_type nnc);
- size_type nrows(void) const { return nr; }
- size_type ncols(void) const { return nc; }
+ size_type nrows() const { return nr; }
+ size_type ncols() const { return nc; }
void swap(csr_matrix<T, IND_TYPE, shift> &m) {
std::swap(pr, m.pr);
std::swap(ir,m.ir); std::swap(jc, m.jc);
@@ -801,17 +801,17 @@ namespace gmm
typedef typename linalg_traits<MAT>::value_type value_type;
typedef typename linalg_traits<MAT>::reference reference;
- size_type nrows(void) const { return introw[nrowblocks_-1].max; }
- size_type ncols(void) const { return intcol[ncolblocks_-1].max; }
- size_type nrowblocks(void) const { return nrowblocks_; }
- size_type ncolblocks(void) const { return ncolblocks_; }
+ size_type nrows() const { return introw[nrowblocks_-1].max; }
+ size_type ncols() const { return intcol[ncolblocks_-1].max; }
+ size_type nrowblocks() const { return nrowblocks_; }
+ size_type ncolblocks() const { return ncolblocks_; }
const sub_interval &subrowinterval(size_type i) const { return introw[i]; }
const sub_interval &subcolinterval(size_type i) const { return intcol[i]; }
const MAT &block(size_type i, size_type j) const
{ return blocks[j*ncolblocks_+i]; }
MAT &block(size_type i, size_type j)
{ return blocks[j*ncolblocks_+i]; }
- void do_clear(void);
+ void do_clear();
// to be done : read and write access to a component
value_type operator() (size_type i, size_type j) const {
size_type k, l;
@@ -833,7 +833,7 @@ namespace gmm
template <typename CONT> void resize(const CONT &c1, const CONT &c2);
template <typename CONT> block_matrix(const CONT &c1, const CONT &c2)
{ resize(c1, c2); }
- block_matrix(void) {}
+ block_matrix() {}
};
@@ -867,7 +867,7 @@ namespace gmm
{ GMM_ASSERT1(false, "Sorry, to be done"); }
};
- template <typename MAT> void block_matrix<MAT>::do_clear(void) {
+ template <typename MAT> void block_matrix<MAT>::do_clear() {
for (size_type j = 0, l = 0; j < ncolblocks_; ++j)
for (size_type i = 0, k = 0; i < nrowblocks_; ++i)
clear(block(i,j));
@@ -973,8 +973,8 @@ namespace gmm {
mpi_distributed_matrix(size_type n, size_type m) : M(n, m) {}
mpi_distributed_matrix() {}
- const MAT &local_matrix(void) const { return M; }
- MAT &local_matrix(void) { return M; }
+ const MAT &local_matrix() const { return M; }
+ MAT &local_matrix() { return M; }
};
template <typename MAT> inline MAT &eff_matrix(MAT &m) { return m; }
diff --git a/tests/wave_equation.cc b/tests/wave_equation.cc
index 45b16457..c8f39a62 100644
--- a/tests/wave_equation.cc
+++ b/tests/wave_equation.cc
@@ -117,21 +117,21 @@ struct wave_equation_problem {
std::string datafilename;
bgeot::md_param PARAM;
- bool solve(void);
- void init(void);
+ bool solve();
+ void init();
void compute_error();
- wave_equation_problem(void) : mim(mesh), mf_u(mesh), mf_rhs(mesh) {}
+ wave_equation_problem() : mim(mesh), mf_u(mesh), mf_rhs(mesh) {}
};
/* Read parameters from the .param file, build the mesh, set finite element
* and integration methods and selects the boundaries.
*/
-void wave_equation_problem::init(void) {
+void wave_equation_problem::init() {
std::string MESH_TYPE = PARAM.string_value("MESH_TYPE","Mesh type ");
std::string FEM_TYPE = PARAM.string_value("FEM_TYPE","FEM name");
std::string INTEGRATION = PARAM.string_value("INTEGRATION",
- "Name of integration method");
+ "Name of integration method");
cout << "MESH_TYPE=" << MESH_TYPE << "\n";
cout << "FEM_TYPE=" << FEM_TYPE << "\n";
cout << "INTEGRATION=" << INTEGRATION << "\n";
@@ -142,9 +142,9 @@ void wave_equation_problem::init(void) {
N = pgt->dim();
std::vector<size_type> nsubdiv(N);
std::fill(nsubdiv.begin(),nsubdiv.end(),
- PARAM.int_value("NX", "Nomber of space steps "));
+ PARAM.int_value("NX", "Nomber of space steps "));
getfem::regular_unit_mesh(mesh, nsubdiv, pgt,
- PARAM.int_value("MESH_NOISED") != 0);
+ PARAM.int_value("MESH_NOISED") != 0);
bgeot::base_matrix M(N,N);
for (size_type i=0; i < N; ++i) {
@@ -167,11 +167,11 @@ void wave_equation_problem::init(void) {
sol_c = PARAM.real_value("C", "Diffusion coefficient");
residual = PARAM.real_value("RESIDUAL");
dirichlet_version = PARAM.int_value("DIRICHLET_VERSION",
- "Type of Dirichlet contion");
+ "Type of Dirichlet contion");
if (dirichlet_version == 1)
dirichlet_coefficient = PARAM.real_value("DIRICHLET_COEFFICIENT",
- "Penalization coefficient for "
- "Dirichlet condition");
+ "Penalization coefficient for "
+ "Dirichlet condition");
if (residual == 0.) residual = 1e-10;
sol_K.resize(N);
for (size_type j = 0; j < N; j++)
@@ -190,12 +190,12 @@ void wave_equation_problem::init(void) {
std::string data_fem_name = PARAM.string_value("DATA_FEM_TYPE");
if (data_fem_name.size() == 0) {
GMM_ASSERT1(pf_u->is_lagrange(), "You are using a non-lagrange FEM. "
- << "In that case you need to set "
- << "DATA_FEM_TYPE in the .param file");
+ << "In that case you need to set "
+ << "DATA_FEM_TYPE in the .param file");
mf_rhs.set_finite_element(mesh.convex_index(), pf_u);
} else {
mf_rhs.set_finite_element(mesh.convex_index(),
- getfem::fem_descriptor(data_fem_name));
+ getfem::fem_descriptor(data_fem_name));
}
/* set boundary conditions
@@ -216,7 +216,7 @@ void wave_equation_problem::init(void) {
}
}
-bool wave_equation_problem::solve(void) {
+bool wave_equation_problem::solve() {
dal::bit_vector transient_bricks;
@@ -245,7 +245,7 @@ bool wave_equation_problem::solve(void) {
gmm::copy(F, model.set_real_variable("NeumannData", 0));
gmm::copy(F, model.set_real_variable("NeumannData", 1));
transient_bricks.add(getfem::add_normal_source_term_brick
- (model, mim, "u", "NeumannData", NEUMANN_BOUNDARY_NUM));
+ (model, mim, "u", "NeumannData",
NEUMANN_BOUNDARY_NUM));
// Dirichlet condition.
gmm::resize(F, mf_rhs.nb_dof());
@@ -270,7 +270,7 @@ bool wave_equation_problem::solve(void) {
case 1 : // Theta-method
model.add_initialized_scalar_data("theta", theta);
ibddt = getfem::add_basic_d2_on_dt2_brick(model, mim, "u", "v",
- "dt", "theta");
+ "dt", "theta");
getfem::add_theta_method_dispatcher(model, transient_bricks, "theta");
alpha = theta;
break;
@@ -278,7 +278,7 @@ bool wave_equation_problem::solve(void) {
model.add_initialized_scalar_data("alpha", 0.5);
alpha = 0.5;
ibddt = getfem::add_basic_d2_on_dt2_brick(model, mim, "u", "v",
- "dt", "alpha");
+ "dt", "alpha");
getfem::add_midpoint_dispatcher(model, transient_bricks);
break;
case 3 : // Newmark
@@ -286,7 +286,7 @@ bool wave_equation_problem::solve(void) {
model.add_initialized_scalar_data("twobeta", alpha);
model.add_initialized_scalar_data("gamma", gamma);
ibddt = getfem::add_basic_d2_on_dt2_brick(model, mim, "u", "v",
- "dt", "twobeta");
+ "dt", "twobeta");
getfem::add_theta_method_dispatcher(model, transient_bricks, "twobeta");
break;
default : GMM_ASSERT1(false, "Unvalid time integration scheme");
@@ -318,15 +318,15 @@ bool wave_equation_problem::solve(void) {
switch (scheme) {
case 1 : // Theta-method
getfem::velocity_update_for_order_two_theta_method
- (model, "u", "v", "dt", "theta");
+ (model, "u", "v", "dt", "theta");
break;
case 2 : // Midpoint
getfem::velocity_update_for_order_two_theta_method
- (model, "u", "v", "dt", "alpha");
+ (model, "u", "v", "dt", "alpha");
break;
case 3 : // Newmark
getfem::velocity_update_for_Newmark_scheme
- (model, ibddt, "u", "v", "dt", "twobeta", "gamma");
+ (model, ibddt, "u", "v", "dt", "twobeta", "gamma");
break;
}
@@ -342,10 +342,10 @@ bool wave_equation_problem::solve(void) {
gmm::copy(model.real_variable("v"), V);
gmm::sub_interval Iu = model.interval_of_variable("u");
scalar_type J
- = gmm::vect_sp(gmm::sub_matrix(model.linear_real_matrix_term(iblap, 0),
+ = gmm::vect_sp(gmm::sub_matrix(model.linear_real_matrix_term(iblap, 0),
Iu, Iu), U, U) * 0.5
- + gmm::vect_sp(model.linear_real_matrix_term(ibddt, 0), V, V)
- * 0.5 * dt*dt*alpha;
+ + gmm::vect_sp(model.linear_real_matrix_term(ibddt, 0), V, V)
+ * 0.5 * dt*dt*alpha;
cout << "Energy : " << J << endl;
}