G+Smo  25.01.0
Geometry + Simulation Modules
 
Loading...
Searching...
No Matches
Tutorial: Non-Linear Quasi-Static analysis using solids

Static simulations of a solid

Annotated source file

Here is the full file nonlinear_solid_arcLength.cpp. Clicking on a function or class name will lead you to its reference documentation.

#include <gismo.h>
#ifdef gsElasticity_ENABLED
#endif
using namespace gismo;
#ifdef gsElasticity_ENABLED
int main(int argc, char *argv[])
{
bool plot = false;
index_t numRefine = 1;
index_t numElevate = 1;
gsCmdLine cmd("Linear shell tutorial.");
cmd.addInt( "e", "degreeElevation","Number of degree elevation steps to perform before solving (0: equalize degree in all directions)", numElevate );
cmd.addInt( "r", "uniformRefine", "Number of Uniform h-refinement steps to perform before solving", numRefine );
cmd.addSwitch("plot", "Create a ParaView visualization file with the solution", plot);
try { cmd.getValues(argc,argv); } catch (int rv) { return rv; }
// Initialize [ori]ginal and [def]ormed geometry
std::string fileName = "paraboloid_volume.xml";
gsReadFile<>(fileName, ori);
// p-refine
if (numElevate!=0)
ori.degreeElevate(numElevate);
// h-refine (only in first two directions)
for (int r =0; r < numRefine; ++r)
{
ori.uniformRefine(1,1,0);
ori.uniformRefine(1,1,1);
}
// creating basis
gsMultiBasis<> basis(ori);
// Define the boundary conditions object
// Set the geometry map for computation of the Dirichlet BCs
bc.setGeoMap(ori);
// Set the boundary conditions
gsFunctionExpr<> surf_force("0","0","-1e10",3);
for (index_t c=0; c!=3; c++)
{
bc.addCornerValue(boundary::southwestfront, 0.0, 0, c); // (corner,value, patch, unknown)
bc.addCornerValue(boundary::southeastfront, 0.0, 0, c); // (corner,value, patch, unknown)
bc.addCornerValue(boundary::northwestfront, 0.0, 0, c); // (corner,value, patch, unknown)
bc.addCornerValue(boundary::northeastfront, 0.0, 0, c); // (corner,value, patch, unknown)
}
bc.addCondition(boundary::front, condition_type::neumann, &surf_force);
// The surface force is defined in the physical space, i.e. 3D
gsFunctionExpr<> body_force("0","0","0",3);
gsElasticityAssembler<real_t> assembler(ori,basis,bc,body_force);
assembler.options().setReal("YoungsModulus",1.E9);
assembler.options().setReal("PoissonsRatio",0.45);
assembler.options().setInt("MaterialLaw",material_law::saint_venant_kirchhoff);
assembler.options().setInt("DirichletValues",dirichlet::l2Projection);
assembler.assemble();
gsSparseMatrix<> K = assembler.matrix();
gsVector<> F = assembler.rhs();
std::vector<gsMatrix<> > fixedDofs = assembler.allFixedDofs();
// Function for the Jacobian
{
assembler.assemble(x,fixedDofs);
m = assembler.matrix();
return true;
};
// Function for the Residual
gsStructuralAnalysisOps<real_t>::ALResidual_t ALResidual = [&fixedDofs,&assembler,&F](gsVector<real_t> const &x, real_t lam, gsVector<real_t> & v)
{
assembler.assemble(x,fixedDofs);
v = F - lam * F - assembler.rhs(); // assembler rhs - force = Finternal
return true;
};
gsInfo<<"Solving system with "<<assembler.numDofs()<<" DoFs\n";
gsALMCrisfield<real_t> solver(Jacobian,ALResidual,F);
solver.options().setSwitch("Verbose",true);
solver.setLength(0.1);
solver.applyOptions();
solver.initialize();
index_t step = 50;
gsParaviewCollection collection("Deformation");
gsVector<> solVector;
gsMultiPatch<> displ, def;
for (index_t k=0; k<step; k++)
{
gsInfo<<"Load step "<< k<<"\n";
solver.step();
solVector = solver.solutionU();
// constructing solution as an IGA function
assembler.constructSolution(solVector,assembler.allFixedDofs(),displ);
gsMultiPatch<> def = ori;
for (index_t p = 0; p < def.nPieces(); ++p)
def.patch(p).coefs() += displ.patch(p).coefs();
// ! [Export visualization in ParaView]
if (plot)
{
// Plot the displacements on the deformed geometry
gsField<> solField(def, displ);
std::string outputName = "Deformation" + std::to_string(k) + "_";
gsWriteParaview<>( solField, outputName, 1000, true);
collection.addPart(outputName + "0.vts",k);
}
}
// ![Save the paraview collection]
if (plot)
collection.save();
// ![Save the paraview collection]
return EXIT_SUCCESS;
#else
GISMO_ERROR("The tutorial needs to be compiled with gsElasticity enabled");
return EXIT_FAILED;
#endif
}// end main
Performs the Crisfield arc length method to solve a nonlinear equation system.
Definition gsALMCrisfield.h:30
Class containing a set of boundary conditions.
Definition gsBoundaryConditions.h:342
void addCondition(int p, boxSide s, condition_type::type t, gsFunctionSet< T > *f, short_t unknown=0, bool parametric=false, int comp=-1)
Adds another boundary condition.
Definition gsBoundaryConditions.h:650
void addCornerValue(boxCorner c, T value, int p=0, short_t unknown=0, int component=-1)
Adds a boundary condition with value on a corner c of patch p for unknown component.
Definition gsBoundaryConditions.h:726
void setGeoMap(const gsFunctionSet< T > &gm)
Set the geometry map to evaluate boundary conditions.
Definition gsBoundaryConditions.h:916
Class for command-line argument parsing.
Definition gsCmdLine.h:57
Assembles the stiffness matrix and the right-hand side vector for linear and nonlinear elasticity for...
Definition gsElasticityAssembler.h:32
A scalar of vector field defined on a m_parametric geometry.
Definition gsField.h:55
Class defining a multivariate (real or vector) function given by a string mathematical expression.
Definition gsFunctionExpr.h:52
Holds a set of patch-wise bases and their topology information.
Definition gsMultiBasis.h:37
Container class for a set of geometry patches and their topology, that is, the interface connections ...
Definition gsMultiPatch.h:100
void degreeElevate(short_t const elevationSteps=1, short_t const dir=-1)
Elevate the degree of all patches by elevationSteps, preserves smoothness.
Definition gsMultiPatch.hpp:282
gsGeometry< T > & patch(size_t i) const
Return the i-th patch.
Definition gsMultiPatch.h:292
index_t nPieces() const
Number of pieces in the domain of definition.
Definition gsMultiPatch.h:193
void uniformRefine(int numKnots=1, int mul=1, short_t const dir=-1)
Refine uniformly all patches by inserting numKnots in each knot-span with multipliplicity mul.
Definition gsMultiPatch.hpp:271
This class is used to create a Paraview .pvd (collection) file.
Definition gsParaviewCollection.h:77
Reads an object from a data file, if such the requested object exists in the file.
Definition gsReadFile.h:43
Sparse matrix class, based on gsEigen::SparseMatrix.
Definition gsSparseMatrix.h:139
A vector with arbitrary coefficient type and fixed or dynamic size.
Definition gsVector.h:37
Main header to be included by clients using the G+Smo library.
Performs the arc length method to solve a nonlinear equation system.
#define index_t
Definition gsConfig.h:32
#define GISMO_ERROR(message)
Definition gsDebug.h:118
#define gsInfo
Definition gsDebug.h:43
Provides linear and nonlinear elasticity systems for 2D plain strain and 3D continua.
Provides isogeometric meshing and modelling routines.
Class providing Structural Analysis Utilities.
Allows to write several fields defined on the same geometry in one file, making it easier to operate ...
The G+Smo namespace, containing all definitions for the library.
@ neumann
Neumann type.
Definition gsBoundaryConditions.h:33
std::function< bool(gsVector< T > const &, const T, gsVector< T > &)> ALResidual_t
Arc-Length Residual, Fint-lambda*Fext.
Definition gsStructuralAnalysisTypes.h:70
std::function< bool(gsVector< T > const &, gsSparseMatrix< T > &) > Jacobian_t
Jacobian.
Definition gsStructuralAnalysisTypes.h:86
@ saint_venant_kirchhoff
sigma = 2*mu*eps + lambda*tr(eps)*I
Definition gsBaseUtils.h:132