diff --git a/src/model/elastic_functional.cpp b/src/model/elastic_functional.cpp index e4ebd0c..29c9e92 100644 --- a/src/model/elastic_functional.cpp +++ b/src/model/elastic_functional.cpp @@ -1,71 +1,71 @@ /* * SPDX-License-Indentifier: AGPL-3.0-or-later * * Copyright (©) 2016-2022 EPFL (École Polytechnique Fédérale de Lausanne), * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program 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 Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * */ /* -------------------------------------------------------------------------- */ #include "elastic_functional.hh" /* -------------------------------------------------------------------------- */ namespace tamaas { namespace functional { Real ElasticFunctionalPressure::computeF(GridBase& pressure, GridBase& dual) const { // This doesn't work if dual is multi-component *buffer = dual; // this can get large const unsigned long long n = dual.getGlobalNbPoints(); - return (pressure.dot(*buffer) / 2 - pressure.dot(surface)) / n / n; + return (pressure.dot(*buffer) / 2 - pressure.dot(surface)) / n; } /* -------------------------------------------------------------------------- */ void ElasticFunctionalPressure::computeGradF(GridBase& pressure, GridBase& gradient) const { this->op.apply(pressure, *buffer); // This doesn't work if dual is multi-component *buffer -= surface; gradient += *buffer; } /* -------------------------------------------------------------------------- */ Real ElasticFunctionalGap::computeF(GridBase& gap, GridBase& dual) const { // This doesn't work if dual is multi-component *buffer = gap; *buffer += surface; const UInt n = dual.getGlobalNbPoints(); const Real F = 0.5 * buffer->dot(dual); - return F / n / n; // avoid integer overflow + return F / n; // avoid integer overflow } /* -------------------------------------------------------------------------- */ void ElasticFunctionalGap::computeGradF(GridBase& gap, GridBase& gradient) const { *buffer = gap; *buffer += surface; // Now we have displacements this->op.apply(*buffer, *buffer); gradient += *buffer; } } // namespace functional } // namespace tamaas