From 4993f85e36520b3bc926c4188f06be98b47cad6f Mon Sep 17 00:00:00 2001 From: Hugo Verhelst Date: Fri, 1 Mar 2024 15:41:20 +0100 Subject: [PATCH 1/2] add documentation --- src/gsDynamicSolvers/gsDynamicBathe.h | 10 +- src/gsDynamicSolvers/gsDynamicExplicitEuler.h | 3 - src/gsDynamicSolvers/gsDynamicImplicitEuler.h | 5 +- src/gsDynamicSolvers/gsDynamicNewmark.h | 10 +- src/gsDynamicSolvers/gsDynamicRK4.h | 5 +- src/gsDynamicSolvers/gsDynamicWilson.h | 10 +- src/gsDynamicSolvers/gsDynamicXBraid.h | 96 ++++++++++++++----- 7 files changed, 94 insertions(+), 45 deletions(-) diff --git a/src/gsDynamicSolvers/gsDynamicBathe.h b/src/gsDynamicSolvers/gsDynamicBathe.h index 3e63d7f..6f06140 100644 --- a/src/gsDynamicSolvers/gsDynamicBathe.h +++ b/src/gsDynamicSolvers/gsDynamicBathe.h @@ -1,6 +1,11 @@ /** @file gsDynamicBathe.h - @brief Class to perform time integration of second-order structural dynamics systems using the Explicit Euler method + @brief Class to perform time integration of second-order structural dynamics systems using the Bathe method + + For the Bathe method, see: + Bathe, K. J., & Baig, M. M. I. (2005). + On a composite implicit time integration procedure for nonlinear dynamics. + Computers & Structures, 83(31-32), 2513-2524. This file is part of the G+Smo library. @@ -9,9 +14,6 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/. Author(s): H.M. Verhelst (2019-..., TU Delft) - - TODO (June 2023): - * Change inputs to const references! */ #pragma once diff --git a/src/gsDynamicSolvers/gsDynamicExplicitEuler.h b/src/gsDynamicSolvers/gsDynamicExplicitEuler.h index b4f68ec..88146bd 100644 --- a/src/gsDynamicSolvers/gsDynamicExplicitEuler.h +++ b/src/gsDynamicSolvers/gsDynamicExplicitEuler.h @@ -9,9 +9,6 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/. Author(s): H.M. Verhelst (2019-..., TU Delft) - - TODO (June 2023): - * Change inputs to const references! */ #pragma once diff --git a/src/gsDynamicSolvers/gsDynamicImplicitEuler.h b/src/gsDynamicSolvers/gsDynamicImplicitEuler.h index 3d54dec..f34d757 100644 --- a/src/gsDynamicSolvers/gsDynamicImplicitEuler.h +++ b/src/gsDynamicSolvers/gsDynamicImplicitEuler.h @@ -1,6 +1,6 @@ /** @file gsDynamicImplicitEuler.h - @brief Class to perform time integration of second-order structural dynamics systems using the Explicit Euler method + @brief Class to perform time integration of second-order structural dynamics systems using the Implicit Euler method This file is part of the G+Smo library. @@ -9,9 +9,6 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/. Author(s): H.M. Verhelst (2019-..., TU Delft) - - TODO (June 2023): - * Change inputs to const references! */ #pragma once diff --git a/src/gsDynamicSolvers/gsDynamicNewmark.h b/src/gsDynamicSolvers/gsDynamicNewmark.h index 1fdd2bc..e0a9101 100644 --- a/src/gsDynamicSolvers/gsDynamicNewmark.h +++ b/src/gsDynamicSolvers/gsDynamicNewmark.h @@ -1,6 +1,11 @@ /** @file gsDynamicNewmark.h - @brief Class to perform time integration of second-order structural dynamics systems using the Explicit Euler method + @brief Class to perform time integration of second-order structural dynamics systems using the Newmark method + + For the Newmark method, see: + Newmark, N. M. (1959). + A method of computation for structural dynamics. + Journal of the engineering mechanics division, 85(3), 67-94. This file is part of the G+Smo library. @@ -9,9 +14,6 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/. Author(s): H.M. Verhelst (2019-..., TU Delft) - - TODO (June 2023): - * Change inputs to const references! */ #pragma once diff --git a/src/gsDynamicSolvers/gsDynamicRK4.h b/src/gsDynamicSolvers/gsDynamicRK4.h index e7bbe98..eefb1e3 100644 --- a/src/gsDynamicSolvers/gsDynamicRK4.h +++ b/src/gsDynamicSolvers/gsDynamicRK4.h @@ -1,6 +1,6 @@ /** @file gsDynamicRK4.h - @brief Class to perform time integration of second-order structural dynamics systems using the Explicit Euler method + @brief Class to perform time integration of second-order structural dynamics systems using the Runge-Kutta 4 method This file is part of the G+Smo library. @@ -9,9 +9,6 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/. Author(s): H.M. Verhelst (2019-..., TU Delft) - - TODO (June 2023): - * Change inputs to const references! */ #pragma once diff --git a/src/gsDynamicSolvers/gsDynamicWilson.h b/src/gsDynamicSolvers/gsDynamicWilson.h index 34bbfcd..87ec0a7 100644 --- a/src/gsDynamicSolvers/gsDynamicWilson.h +++ b/src/gsDynamicSolvers/gsDynamicWilson.h @@ -1,6 +1,11 @@ /** @file gsDynamicWilson.h - @brief Class to perform time integration of second-order structural dynamics systems using the Explicit Euler method + @brief Class to perform time integration of second-order structural dynamics systems using the Wilson-theta method + + For the Wilson-theta method, see: + Wilson, E. L., Farhoomand, I., & Bathe, K. J. (1972). + Nonlinear dynamic analysis of complex structures. + Earthquake Engineering & Structural Dynamics, 1(3), 241-252. This file is part of the G+Smo library. @@ -9,9 +14,6 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/. Author(s): H.M. Verhelst (2019-..., TU Delft) - - TODO (June 2023): - * Change inputs to const references! */ #pragma once diff --git a/src/gsDynamicSolvers/gsDynamicXBraid.h b/src/gsDynamicSolvers/gsDynamicXBraid.h index 7290f2a..2f48537 100644 --- a/src/gsDynamicSolvers/gsDynamicXBraid.h +++ b/src/gsDynamicSolvers/gsDynamicXBraid.h @@ -1,6 +1,8 @@ - /** @file gsDynamicImplicitEuler.h + /** @file gsDynamicXBraid.h + + @brief This class provides an interface to XBraid for time integration methods deriving from \ref gsDynamicBase + - @brief Class to perform time integration of second-order structural dynamics systems using the Explicit Euler method This file is part of the G+Smo library. @@ -9,16 +11,16 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/. Author(s): H.M. Verhelst (2019-..., TU Delft) - - TODO (June 2023): - * Change inputs to const references! */ #pragma once #include -#include #include +#ifdef gsXbraid_ENABLED +#include +#endif + namespace gismo { @@ -38,7 +40,16 @@ class gsDynamicXBraid : public gsXBraid< gsMatrix > virtual ~gsDynamicXBraid() {}; +#ifdef gsXbraid_ENABLED /// Constructor + /// + /// @param[in] solver A dynamic solver + /// @param[in] comm The MPI communication channel + /// @param[in] tstart The start time of the simulation + /// @param[in] tend The end time of the simulation + /// @param[in] numDofs The number of degrees of freedom + /// @param[in] numSteps The number time steps to perform + /// gsDynamicXBraid( const gsDynamicBase * solver, const gsMpiComm& comm, @@ -54,9 +65,33 @@ class gsDynamicXBraid : public gsXBraid< gsMatrix > defaultOptions(); m_callback = [](const index_t&,const T&,const gsVector&,const gsVector&,const gsVector&){return;}; // set empty callback } +#else + /// Constructor + /// + /// @param[in] solver A dynamic solver + /// @param[in] comm The MPI communication channel + /// @param[in] tstart The start time of the simulation + /// @param[in] tend The end time of the simulation + /// @param[in] numDofs The number of degrees of freedom + /// @param[in] numSteps The number time steps to perform + /// + gsDynamicXBraid( + const gsDynamicBase * solver, + const gsMpiComm& comm, + const T& tstart, + const T& tend, + const index_t numDofs, + index_t numSteps = 10) + { + GISMO_ERROR("XBraid needs to be enabled to use the gsDynamicXBraid interface") + } +#endif // Member functions public: + /** + * @brief Dets the default options + */ void defaultOptions() { // see gsXBraid/filedata/pde/heat2d_square_ibvp1.xml @@ -87,6 +122,9 @@ class gsDynamicXBraid : public gsXBraid< gsMatrix > m_options.addSwitch("extraVerbose", "Extra verbosity", 0); } + /** + * @brief Initializes the class + */ void initialize() { // see gsXBraid/examples/xbraid_heatEquation_example.cpp @@ -114,7 +152,8 @@ class gsDynamicXBraid : public gsXBraid< gsMatrix > else this->SetRelTol(m_options.getReal("relTol")); } - /// Initializes a vector +#ifdef gsXbraid_ENABLED + /// See \ref gsXBraid for the documentation braid_Int Init(braid_Real t, braid_Vector *u_ptr) override { gsMatrix* u = new gsMatrix(3*m_numDofs, 1); @@ -132,11 +171,31 @@ class gsDynamicXBraid : public gsXBraid< gsMatrix > *u_ptr = (braid_Vector) u; return braid_Int(0); } +#endif + /** + * @brief Access the options of the class + * + * @return The options stored in the class + */ gsOptionList & options() { return m_options; } + + /** + * @brief Set the class options + * + * @param[in] options The options to be set + */ void setOptions(gsOptionList options) {m_options.update(options,gsOptionList::addIfUnknown); }; - /// Performs a single step of the parallel-in-time multigrid + /** + * @brief Provide a callback function to be executed after the simulation + * + * @param[in] callback The callback function + */ + void setCallback(callback_type callback) const {m_callback = callback;} + +#ifdef gsXbraid_ENABLED + /// See \ref gsXBraid for the documentation braid_Int Step(braid_Vector u, braid_Vector ustop, braid_Vector fstop, BraidStepStatus &status) override { gsVector* u_ptr = (gsVector*) u; @@ -190,7 +249,7 @@ class gsDynamicXBraid : public gsXBraid< gsMatrix > return braid_Int(0); } - /// Computes the spatial norm of the given vector + /// See \ref gsXBraid for the documentation braid_Int SpatialNorm( braid_Vector u, braid_Real *norm_ptr) override { @@ -200,16 +259,14 @@ class gsDynamicXBraid : public gsXBraid< gsMatrix > return braid_Int(0); } - /// Sets the size of the MPI communication buffer + /// See \ref gsXBraid for the documentation braid_Int BufSize(braid_Int *size_ptr, BraidBufferStatus &status) override { *size_ptr = sizeof(T)*(m_numDofs*3+2); // +2 comes from rows, cols of the solution vector u. return braid_Int(0); } - void setCallback(callback_type callback) const {m_callback = callback;} - - /// Handles access for input/output + /// See \ref gsXBraid for the documentation braid_Int Access(braid_Vector u, BraidAccessStatus &status) override { gsVector* u_ptr = (gsVector*) u; @@ -222,7 +279,7 @@ class gsDynamicXBraid : public gsXBraid< gsMatrix > return braid_Int(0); } - /// Performs spatial coarsening + /// See \ref gsXBraid for the documentation /* NOTE: This routine is not implemented. How to do it: 1. Make the Coarsen and Refine routines virtual @@ -238,7 +295,7 @@ class gsDynamicXBraid : public gsXBraid< gsMatrix > return braid_Int(0); } - // Performs spatial refinement + /// See \ref gsXBraid for the documentation braid_Int Refine(braid_Vector cu, braid_Vector *fu_ptr, BraidCoarsenRefStatus &status) override { gsMatrix *cu_ptr = (gsMatrix*) cu; @@ -247,7 +304,7 @@ class gsDynamicXBraid : public gsXBraid< gsMatrix > *fu_ptr = (braid_Vector) fu; return braid_Int(0); } - +#endif // Class members protected: @@ -256,11 +313,6 @@ class gsDynamicXBraid : public gsXBraid< gsMatrix > index_t m_numDofs; gsOptionList m_options; mutable callback_type m_callback; - }; -} // namespace gismo - -#ifndef GISMO_BUILD_LIB -#include GISMO_HPP_HEADER(gsDynamicImplicitEuler.hpp) -#endif +} // namespace gismo \ No newline at end of file From 8775fc81d1c588914360bf4af42a518ec046e8db Mon Sep 17 00:00:00 2001 From: Hugo Verhelst Date: Fri, 1 Mar 2024 19:19:41 +0100 Subject: [PATCH 2/2] compiler bug --- src/gsDynamicSolvers/gsDynamicXBraid.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/gsDynamicSolvers/gsDynamicXBraid.h b/src/gsDynamicSolvers/gsDynamicXBraid.h index 2f48537..6b98e1e 100644 --- a/src/gsDynamicSolvers/gsDynamicXBraid.h +++ b/src/gsDynamicSolvers/gsDynamicXBraid.h @@ -2,7 +2,10 @@ @brief This class provides an interface to XBraid for time integration methods deriving from \ref gsDynamicBase + For more information about XBraid, please check \ref gsXBraid or + [XBraid on GitHub] https://github.com/XBraid/xbraid/ + [XBraid cite] XBraid: Parallel multigrid in time. http://llnl.gov/casc/xbraid. This file is part of the G+Smo library. @@ -17,7 +20,7 @@ #include #include -#ifdef gsXbraid_ENABLED +#ifdef gsXBraid_ENABLED #include #endif @@ -40,7 +43,7 @@ class gsDynamicXBraid : public gsXBraid< gsMatrix > virtual ~gsDynamicXBraid() {}; -#ifdef gsXbraid_ENABLED +#ifdef gsXBraid_ENABLED /// Constructor /// /// @param[in] solver A dynamic solver @@ -152,7 +155,7 @@ class gsDynamicXBraid : public gsXBraid< gsMatrix > else this->SetRelTol(m_options.getReal("relTol")); } -#ifdef gsXbraid_ENABLED +#ifdef gsXBraid_ENABLED /// See \ref gsXBraid for the documentation braid_Int Init(braid_Real t, braid_Vector *u_ptr) override { @@ -194,7 +197,7 @@ class gsDynamicXBraid : public gsXBraid< gsMatrix > */ void setCallback(callback_type callback) const {m_callback = callback;} -#ifdef gsXbraid_ENABLED +#ifdef gsXBraid_ENABLED /// See \ref gsXBraid for the documentation braid_Int Step(braid_Vector u, braid_Vector ustop, braid_Vector fstop, BraidStepStatus &status) override {