Skip to content

Commit

Permalink
Merge pull request #35 from gismo/gsElasticity-assemble-fix
Browse files Browse the repository at this point in the history
Fixed ambiguous assemble() overrides
  • Loading branch information
hverhelst authored Dec 10, 2024
2 parents 67dc696 + aab2c9f commit 3ca0eaf
Show file tree
Hide file tree
Showing 44 changed files with 496 additions and 87 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ jobs:
- name: "Run for ${{ matrix.os }}"
shell: bash
working-directory: ${{runner.workspace}}
run: ctest -S ${{ github.event.repository.name }}/gismo/cmake/ctest_script.cmake -D CTEST_BUILD_NAME="${{ github.event.repository.name }}_actions_$GITHUB_RUN_NUMBER" -D CTEST_SITE="${{ matrix.os }}_[actions]" -D CMAKE_ARGS="-DCMAKE_BUILD_TYPE=$BUILD_TYPE;-DCMAKE_CXX_STANDARD=11;-DGISMO_WITH_XDEBUG=ON;-DGISMO_BUILD_UNITTESTS=ON" -D GISMO_OPTIONAL="${{ github.event.repository.name }}" -Q
run: ctest -S ${{ github.event.repository.name }}/gismo/cmake/ctest_script.cmake -D CTEST_BUILD_NAME="${{ github.event.repository.name }}_actions_$GITHUB_RUN_NUMBER" -D CTEST_CONFIGURATION_TYPE=RelWithDebInfo -D LABELS_FOR_SUBPROJECTS="gsElasticity-examples" -D CTEST_SITE="${{ matrix.os }}_[actions]" -D CMAKE_ARGS="-DCMAKE_BUILD_TYPE=$BUILD_TYPE;-DCMAKE_CXX_STANDARD=11;-DGISMO_WITH_XDEBUG=ON;-DGISMO_BUILD_UNITTESTS=ON" -D GISMO_OPTIONAL="${{ github.event.repository.name }}" -Q
27 changes: 17 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,22 @@ install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}"
FILES_MATCHING PATTERN "*.h" )

# add filedata folder
add_definitions(-DELAST_DATA_DIR="${CMAKE_CURRENT_SOURCE_DIR}/filedata/")
add_definitions(-DELAST_DATA_DIR="${CMAKE_CURRENT_SOURCE_DIR}/filedata/")

# add example files
aux_cpp_directory(${CMAKE_CURRENT_SOURCE_DIR}/examples FILES)
foreach(file ${FILES})
add_gismo_executable(${file})
get_filename_component(tarname ${file} NAME_WE) # name without extension
set_property(TEST ${tarname} PROPERTY LABELS "${PROJECT_NAME}")
set_target_properties(${tarname} PROPERTIES FOLDER "${PROJECT_NAME}")
# install the example executables (optionally)
install(TARGETS ${tarname} DESTINATION "${BIN_INSTALL_DIR}" COMPONENT exe OPTIONAL)
endforeach(file ${FILES})
if(GISMO_BUILD_EXAMPLES)
add_custom_target(${PROJECT_NAME}-examples)
add_subdirectory(examples)
else()
add_subdirectory(examples EXCLUDE_FROM_ALL)
endif(GISMO_BUILD_EXAMPLES)

# Print the contents of {PROJECT_NAME}-examples
get_property(dirs TARGET ${PROJECT_NAME}-examples PROPERTY BUILDSYSTEM_TARGETS)
message(STATUS "dirs: ${dirs}")


# # add unittests
# aux_gs_cpp_directory(${PROJECT_SOURCE_DIR}/unittests unittests_SRCS)
# set(gismo_UNITTESTS ${gismo_UNITTESTS} ${unittests_SRCS}
# CACHE INTERNAL "gismo list of unittests")
25 changes: 25 additions & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
######################################################################
## CMakeLists.txt --- gsStructuralAnalysis/examples
## This file is part of the G+Smo library.
##
## Author: Angelos Mantzaflaris, Hugo Verhelst
## Copyright (C) 2023
######################################################################

# add example files
aux_cpp_directory(${CMAKE_CURRENT_SOURCE_DIR} FILES)
foreach(file ${FILES})
add_gismo_executable(${file})
get_filename_component(tarname ${file} NAME_WE) # name without extension
set_property(TEST ${tarname} PROPERTY LABELS "${PROJECT_NAME}-examples")
if(GISMO_BUILD_EXAMPLES)
set_target_properties(${tarname} PROPERTIES FOLDER "${PROJECT_NAME}")
else(GISMO_BUILD_EXAMPLES)
set_target_properties(${tarname} PROPERTIES
FOLDER "${PROJECT_NAME}"
EXCLUDE_FROM_ALL TRUE)
endif(GISMO_BUILD_EXAMPLES)
add_dependencies(${PROJECT_NAME}-examples ${tarname})
# install the example executables (optionally)
install(TARGETS ${tarname} DESTINATION "${BIN_INSTALL_DIR}" COMPONENT exe OPTIONAL)
endforeach(file ${FILES})
2 changes: 1 addition & 1 deletion examples/aroundCylinder_NS_2D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ int main(int argc, char* argv[]){
real_t meanVelocity = 0.2; // inflow velocity
real_t density = 1.;
// space discretization
index_t numUniRef = 3;
index_t numUniRef = 1; //was 3
index_t numDegElev = 0;
index_t numBLRef = 1;
bool subgridOrTaylorHood = false;
Expand Down
4 changes: 2 additions & 2 deletions examples/aroundCylinder_NS_2Dt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ int main(int argc, char* argv[]){
real_t meanVelocity = 1; // inflow velocity
real_t density = 1.0;
// space discretization
index_t numUniRef = 3;
index_t numUniRef = 1; //was 3
index_t numDegElev = 0;
index_t numBLRef = 1;
bool subgridOrTaylorHood = false;
// time integration
real_t timeSpan = 10;
real_t timeSpan = 0.01; // was 10
real_t timeStep = 0.01;
real_t theta = 0.5;
bool imexOrNewton = false;
Expand Down
4 changes: 2 additions & 2 deletions examples/biceps_activeMuscle_3D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ int main(int argc, char* argv[]){
gsVector<> fiberDirection(3);
fiberDirection << 1.,0.,0.;
// space discretization
index_t numUniRefDirX = 2;
index_t numUniRefDirX = 0;
index_t numUniRef = 0;
index_t numDegElev = 0;
bool subgridOrTaylorHood = false;
// output
index_t numPlotPoints = 10000;
index_t numPlotPoints = 0;

// minimalistic user interface for terminal
gsCmdLine cmd("This is a simulation of active muscle behavior.");
Expand Down
6 changes: 3 additions & 3 deletions examples/biceps_activeMuscle_3Dt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ int main(int argc, char* argv[]){
gsVector<> fiberDirection(3);
fiberDirection << 1.,0.,0.;
// space discretization
index_t numUniRefDirX = 2;
index_t numUniRefDirX = 0;
index_t numUniRef = 0;
index_t numDegElev = 0;
bool subgridOrTaylorHood = false;
// time integration
real_t timeSpan = 2;
real_t timeSpan = 0.1; // was 2.0
real_t timeStep = 0.1;
// output
index_t numPlotPoints = 100000;
index_t numPlotPoints = 0;

// minimalistic user interface for terminal
gsCmdLine cmd("This is a simulation of active muscle behavior.");
Expand Down
4 changes: 2 additions & 2 deletions examples/flappingBeam_CFD3_NS_2Dt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ int main(int argc, char* argv[]){
real_t meanVelocity = 2; // inflow velocity
real_t density = 1.0e3;
// space discretization
index_t numUniRef = 3;
index_t numUniRef = 1;// was 3
index_t numDegElev = 0;
index_t numBLRef = 1;
bool subgridOrTaylorHood = false;
// time integration
real_t timeSpan = 10;
real_t timeSpan = 0.01; // was 10
real_t timeStep = 0.01;
real_t theta = 0.5;
bool imexOrNewton = false;
Expand Down
2 changes: 1 addition & 1 deletion examples/flappingBeam_FSI2_coupledFSI_2Dt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ int main(int argc, char* argv[])
index_t numUniRef = 3;
// time integration
real_t timeStep = 0.01;
real_t timeSpan = 15.;
real_t timeSpan = 0.02; //was 15.
real_t thetaFluid = 0.5;
real_t thetaSolid = 1.;
index_t maxCouplingIter = 10;
Expand Down
6 changes: 3 additions & 3 deletions examples/muscleBeam_activeMuscle_3Dt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ int main(int argc, char* argv[]){
for (size_t p = 0; p < geometry.nPatches(); ++p)
for (index_t i = 0; i < numUniRefDirX; ++i)
{
static_cast<gsTensorNurbsBasis<3,real_t> &>(basisDisplacement.basis(p)).knots(0).uniformRefine();
static_cast<gsTensorNurbsBasis<3,real_t> &>(basisPressure.basis(p)).knots(0).uniformRefine();
basisDisplacement.basis(p).uniformRefine(1,1,0);
basisPressure.basis(p).uniformRefine(1,1,0);
}
// additional displacement refinement for stable mixed FEM
if (!subgridOrTaylorHood) // subgrid
Expand All @@ -105,7 +105,7 @@ int main(int argc, char* argv[]){
gsConstantFunction<> prestressRight(prestress,0.,0.,3);

// boundary conditions
gsBoundaryConditions<> bcInfo;
gsBoundaryConditions<> bcInfo;
for (size_t p = 0; p < geometry.nPatches(); ++p)
{
bcInfo.addCondition(p,boundary::west,condition_type::neumann,&prestressLeft);
Expand Down
6 changes: 4 additions & 2 deletions examples/muscleBeam_mixedNonLinElast_3D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ int main(int argc, char* argv[]){
for (size_t p = 0; p < geometry.nPatches(); ++p)
for (index_t i = 0; i < numUniRefDirX; ++i)
{
static_cast<gsTensorNurbsBasis<3,real_t> &>(basisDisplacement.basis(p)).knots(0).uniformRefine();
static_cast<gsTensorNurbsBasis<3,real_t> &>(basisPressure.basis(p )).knots(0).uniformRefine();
basisDisplacement.basis(p).uniformRefine(1,1,0);
basisPressure.basis(p).uniformRefine(1,1,0);
}
// additional displacement refinement for stable mixed FEM
if (!subgridOrTaylorHood) // subgrid
Expand Down Expand Up @@ -97,6 +97,8 @@ int main(int argc, char* argv[]){
gsElasticityAssembler<real_t> assembler(geometry,basisDisplacement,basisPressure,bcInfo,gravity);
assembler.options().setReal("YoungsModulus",youngsModulus);
assembler.options().setReal("PoissonsRatio",poissonsRatio);
assembler.options().setInt("MaterialLaw",material_law::mixed_neo_hooke_ln);

gsInfo << "Initialized system with " << assembler.numDofs() << " dofs.\n";

// setting Newton's method
Expand Down
7 changes: 4 additions & 3 deletions examples/muscleBeam_mixedNonLinElast_3Dt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ int main(int argc, char* argv[]){
index_t numDegElev = 0;
bool subgridOrTaylorHood = false;
// time integration
real_t timeSpan = 1;
real_t timeSpan = 0.01; // was 1.0
real_t timeStep = 0.01;
// output
index_t numPlotPoints = 1000;
Expand Down Expand Up @@ -72,8 +72,8 @@ int main(int argc, char* argv[]){
for (size_t p = 0; p < geometry.nPatches(); ++p)
for (index_t i = 0; i < numUniRefDirX; ++i)
{
static_cast<gsTensorNurbsBasis<3,real_t> &>(basisDisplacement.basis(p)).knots(0).uniformRefine();
static_cast<gsTensorNurbsBasis<3,real_t> &>(basisPressure.basis(p)).knots(0).uniformRefine();
basisDisplacement.basis(p).uniformRefine(1,1,0);
basisPressure.basis(p).uniformRefine(1,1,0);
}
// additional displacement refinement for stable mixed FEM
if (!subgridOrTaylorHood) // subgrid
Expand Down Expand Up @@ -104,6 +104,7 @@ int main(int argc, char* argv[]){
gsElasticityAssembler<real_t> assembler(geometry,basisDisplacement,basisPressure,bcInfo,gravity);
assembler.options().setReal("YoungsModulus",youngsModulus);
assembler.options().setReal("PoissonsRatio",poissonsRatio);
assembler.options().setInt("MaterialLaw",material_law::mixed_neo_hooke_ln);
gsInfo << "Initialized system with " << assembler.numDofs() << " dofs.\n";

// creating mass assembler
Expand Down
2 changes: 1 addition & 1 deletion examples/spring_nonLinElast_3D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ int main(int argc, char* argv[])
basis.uniformRefine();
for (index_t i = 0; i < numUniRefX; ++i)
for (size_t p = 0; p < geometry.nPatches(); ++p)
static_cast<gsTensorBSplineBasis<3,real_t> &>(basis.basis(p)).knots(2).uniformRefine();
basis.basis(p).uniformRefine(1,1,2);

//=============================================//
// Setting loads and boundary conditions //
Expand Down
22 changes: 11 additions & 11 deletions gsBaseAssembler.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ class gsBaseAssembler : public gsAssembler<T>
const std::vector<gsMatrix<T> > & fixedDDoFs) = 0;

/// assembly procedure for linear problems
virtual void assemble(bool saveEliminationMatrix) {};
virtual void assemble() {};
virtual void assemble(const gsMultiPatch<T> & curSolution)
virtual void assemble(bool /* saveEliminationMatrix */) {};
virtual void assemble() { assemble(false); };
virtual void assemble(const gsMultiPatch<T> & /* curSolution */)
{GISMO_NO_IMPLEMENTATION}

/// Returns number of free degrees of freedom
Expand All @@ -50,17 +50,17 @@ class gsBaseAssembler : public gsAssembler<T>
gsMultiPatch<T> & result,
const gsVector<index_t> & unknowns) const;

virtual void constructSolution(const gsMatrix<T>& solVector,
gsMultiPatch<T>& result, short_t unk = 0) const
virtual void constructSolution(const gsMatrix<T>& /* solVector */,
gsMultiPatch<T>& /* result */, short_t /* unk */ = 0) const
{GISMO_NO_IMPLEMENTATION}
virtual void constructSolution(const gsMatrix<T>& solVector,
gsMultiPatch<T>& result,
const gsVector<index_t> & unknowns) const
virtual void constructSolution(const gsMatrix<T>& /* solVector */,
gsMultiPatch<T>& /* result */,
const gsVector<index_t> & /* unknowns */) const
{GISMO_NO_IMPLEMENTATION}

virtual void constructSolution(const gsMatrix<T> & solVector,
const std::vector<gsMatrix<T> > & fixedDDofs,
gsMultiPatch<T> & result) const {};
virtual void constructSolution(const gsMatrix<T> & /* solVector */,
const std::vector<gsMatrix<T> > & /* fixedDDofs */,
gsMultiPatch<T> & /* result */) const {};

//--------------------- DIRICHLET BC SHENANIGANS ----------------------------------//

Expand Down
11 changes: 8 additions & 3 deletions gsBiharmonicAssembler.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,16 @@ class gsBiharmonicAssembler : public gsBaseAssembler<T>
virtual void refresh();

/// @brief Assembles the matrix
virtual void assemble(bool saveEliminationMatrix = false);
/// @{
virtual void assemble(bool saveEliminationMatrix);

virtual bool assemble(const gsMatrix<T> & solutionVector,
const std::vector<gsMatrix<T> > & fixedDDoFs)
virtual void assemble() { assemble(false); };

using Base::assemble;
virtual bool assemble(const gsMatrix<T> & /* solutionVector */,
const std::vector<gsMatrix<T> > & /* fixedDDoFs */)
{assemble(); return true;}
/// @}

//--------------------- SOLUTION CONSTRUCTION ----------------------------------//

Expand Down
6 changes: 3 additions & 3 deletions gsBiharmonicAssembler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include <gsElasticity/gsBiharmonicAssembler.h>

#include <gsPde/gsPoissonPde.h>
#include <gsElasticity/gsVisitorBiharmonic.h>
#include <gsElasticity/gsVisitorBiharmonicMixed.h>

namespace gismo
{
Expand Down Expand Up @@ -89,8 +89,8 @@ void gsBiharmonicAssembler<T>::assemble(bool saveEliminationMatrix)
eliminationMatrix.reservePerColumn(m_system.numColNz(m_bases[0],m_options));
}

gsVisitorBiharmonic<T> visitor(*m_pde_ptr, saveEliminationMatrix ? &eliminationMatrix : nullptr);
Base::template push<gsVisitorBiharmonic<T> >(visitor);
gsVisitorBiharmonicMixed<T> visitor(*m_pde_ptr, saveEliminationMatrix ? &eliminationMatrix : nullptr);
Base::template push<gsVisitorBiharmonicMixed<T> >(visitor);

m_system.matrix().makeCompressed();

Expand Down
12 changes: 9 additions & 3 deletions gsElPoissonAssembler.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,18 @@ class gsElPoissonAssembler : public gsBaseAssembler<T>
virtual void refresh();

/// @brief Assembles the mass matrix
virtual void assemble(bool saveEliminationMatrix = false);
/// @{
virtual void assemble(bool saveEliminationMatrix);

virtual bool assemble(const gsMatrix<T> & solutionVector,
const std::vector<gsMatrix<T> > & fixedDDoFs)
virtual void assemble() { assemble(false); };

using Base::assemble;
virtual bool assemble(const gsMatrix<T> & /* solutionVector */,
const std::vector<gsMatrix<T> > & /* fixedDDoFs */)
{assemble(); return true;}
/// @}

using Base::constructSolution;
virtual void constructSolution(const gsMatrix<T> & solVector,
const std::vector<gsMatrix<T> > & fixedDoFs,
gsMultiPatch<T> & displacement) const;
Expand Down
9 changes: 4 additions & 5 deletions gsElTimeIntegrator.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,12 @@

#include <gsElasticity/gsBaseAssembler.h>
#include <gsElasticity/gsBaseUtils.h>
#include <gsElasticity/gsElasticityAssembler.h>
#include <gsElasticity/gsMassAssembler.h>

namespace gismo
{

template <class T>
class gsElasticityAssembler;
template <class T>
class gsMassAssembler;

/** @brief Time integation for equations of dynamic elasticity with implicit schemes
*/
template <class T>
Expand Down Expand Up @@ -63,6 +60,7 @@ class gsElTimeIntegrator : public gsBaseAssembler<T>
void makeTimeStep(T timeStep);

/// assemble the linear system for the nonlinear solver
using Base::assemble;
virtual bool assemble(const gsMatrix<T> & solutionVector,
const std::vector<gsMatrix<T> > & fixedDoFs);

Expand Down Expand Up @@ -91,6 +89,7 @@ class gsElTimeIntegrator : public gsBaseAssembler<T>
void constructSolution(gsMultiPatch<T> & displacement) const;

/// construct displacement and pressure (if applicable) using the stiffness assembler
using Base::constructSolution;
void constructSolution(gsMultiPatch<T> & displacement, gsMultiPatch<T> & pressure) const;

/// assemblers' accessors
Expand Down
6 changes: 4 additions & 2 deletions gsElasticityAssembler.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,14 @@ class gsElasticityAssembler : public gsBaseAssembler<T>

//--------------------- SYSTEM ASSEMBLY ----------------------------------//

virtual void assemble() { assemble(false); }

/// @brief Assembles the stiffness matrix and the RHS for the LINEAR ELASTICITY
/// set *assembleMatrix* to false to only assemble the RHS;
/// @{
virtual void assemble(bool saveEliminationMatrix);

virtual void assemble() { assemble(false); };
/// @}

/// Assembles the tangential linear system for Newton's method given the current solution
/// in the form of free and fixed/Dirichelt degrees of freedom.
/// Checks if the current solution is valid (Newton's solver can exit safely if invalid).
Expand Down
Loading

0 comments on commit 3ca0eaf

Please sign in to comment.