G+Smo  25.01.0
Geometry + Simulation Modules
 
Loading...
Searching...
No Matches
Tutorial: Non-Linear Kirchhoff-Love shell analysis using the gsStructuralAnalysis module

This example solves a non-linear shell problem using the gsThinShellAssembler and a static solver from Structural Analysis Module. The goals of the tutorial are the following:

For detailed information about the construction of gsThinShellAssembler and gsMaterialMatrixBase, please consult the tutorials Tutorial: Linear Kirchhoff-Love shell analysis and Tutorial: Non-Linear Kirchhoff-Love shell analysis.

Problem set-up

The set-up of the problem to be solved for this example is identical to the one in Tutorial: Non-Linear Kirchhoff-Love shell analysis. The reader is referred to that example for a full overview of the code.

Jacobian and Residual

In Tutorial: Non-Linear Kirchhoff-Love shell analysis, the Jacobian and Residual operators are already defined as std::function objects. In the present example, we use a similar approach, now defined through gsStructuralAnalysisOps. In particular, the Jacobian and Residual operators are given by:

// Function for the Jacobian
gsStructuralAnalysisOps<real_t>::Jacobian_t Jacobian = [&assembler](gsVector<real_t> const &x, gsSparseMatrix<real_t> & m)
{
gsMultiPatch<> def;
assembler.constructSolution(x,def);
ThinShellAssemblerStatus status = assembler.assembleMatrix(def);
m = assembler.matrix();
};
// Function for the Residual
gsStructuralAnalysisOps<real_t>::Residual_t Residual = [&assembler](gsVector<real_t> const &x, gsVector<real_t> & v)
{
gsMultiPatch<> def;
assembler.constructSolution(x,def);
ThinShellAssemblerStatus status = assembler.assembleVector(def);
v = assembler.rhs();
};
ThinShellAssemblerStatus
Definition gsThinShellAssembler.h:54
@ Success
Assembly is successful.
std::function< bool(gsVector< T > const &, gsSparseMatrix< T > &) > Jacobian_t
Jacobian.
Definition gsStructuralAnalysisTypes.h:86
std::function< bool(gsVector< T > const &, gsVector< T > &)> Residual_t
Residual, Fint-Fext.
Definition gsStructuralAnalysisTypes.h:68

Define the static solver

The Newton-Raphson solver - gsStaticNewton - used in this example is derived from gsStaticBase. There are also other solvers available in the Static solvers submodule. The Newton-Raphson solver needs to be defined using a linear stiffness matrix \(K\), an external force vector \(F\), a Jacobian matrix \(K_{NL}(\mathbf{u})\) and a residual vector \(R(\mathbf{u})\). The latter two are defined above in Jacobian and Residual, whereas the former two are defined like in linear_shell_Assembler:

assembler.assemble();
gsSparseMatrix<> K = assembler.matrix();
gsVector<> F = assembler.rhs();

Consequently, the static solver is constructed as follows:

gsStaticNewton<real_t> solver(K,F,Jacobian,Residual);
solver.options().setInt("verbose",2);
solver.initialize();

Solve the non-linear problem

The gsStaticNewton simply performs Newton-Raphson iterations under the hood. Solving the non-linear system is simply done by using:

gsInfo<<"Solving system with "<<assembler.numDofs()<<" DoFs\n";
gsStatus status = solver.solve();
GISMO_ASSERT(status==gsStatus::Success,"Solver failed");
gsVector<> solVector = solver.solution();
#define gsInfo
Definition gsDebug.h:43
#define GISMO_ASSERT(cond, message)
Definition gsDebug.h:89
gsStatus
Definition gsStructuralAnalysisTypes.h:21
@ Success
Successful.

Where the solution vector is obtained in the last line. As can be seen in the snipped above, the solver returns a status via gsStatus, which can be used to check whether the solver converged or not. Evaluation and export of the solutions is similar as in Tutorial: Linear Kirchhoff-Love shell analysis and Tutorial: Non-Linear Kirchhoff-Love shell analysis.

Annotated source file

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

#include <gismo.h>
#ifdef gsKLShell_ENABLED
#include <gsKLShell/gsKLShell.h>
#endif
using namespace gismo;
// Choose among various shell examples, default = Thin Plate
int main(int argc, char *argv[])
{
#ifdef gsKLShell_ENABLED
bool plot = false;
index_t numRefine = 1;
index_t numElevate = 1;
gsCmdLine cmd("Nonlinear static 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
gsReadFile<>("surfaces/paraboloid.xml", ori);
// p-refine
if (numElevate!=0)
ori.degreeElevate(numElevate);
// h-refine
for (int r =0; r < numRefine; ++r)
gsMultiBasis<> bases(ori);
// Define the boundary conditions object
// Set the geometry map for computation of the Dirichlet BCs
bc.setGeoMap(ori);
// Set the boundary conditions
bc.addCornerValue(boundary::southwest, 0.0, 0, -1); // (corner,value, patch, unknown)
bc.addCornerValue(boundary::southeast, 0.0, 0, -1); // (corner,value, patch, unknown)
bc.addCornerValue(boundary::northwest, 0.0, 0, -1); // (corner,value, patch, unknown)
bc.addCornerValue(boundary::northeast, 0.0, 0, -1); // (corner,value, patch, unknown)
gsVector<> point(2);
gsVector<> load (3);
point<< 0.5, 0.5 ; load << 0, 0.0, -1e4 ;
pLoads.addLoad(point, load, 0 );
// The surface force is defined in the physical space, i.e. 3D
gsFunctionExpr<> force("0","0","0",3);
// Define material parameters
// The material parameters are defined in the physical domain as well (!)
// Define a linear material, see \ref gsMaterialMatrixLinear.h
// The first parameter is the physical domain dimension
// gsMaterialMatrixLinear<3,real_t> materialMatrix(ori,t,E,nu);
std::vector<gsFunctionSet<>*> parameters{&E,&nu};
gsOptionList options;
options.addInt("Material","Material model: (0): SvK | (1): NH | (2): NH_ext | (3): MR | (4): Ogden",1);
options.addInt("Implementation","Implementation: (0): Composites | (1): Analytical | (2): Generalized | (3): Spectral",1);
gsMaterialMatrixBase<real_t>::uPtr materialMatrix = getMaterialMatrix<3,real_t>(ori,t,parameters,options);
// Define the assembler.
// The first parameter is the physical domain dimension
// The second parameter is the real type
// The third parameter controls the bending stiffness
gsThinShellAssembler<3, real_t, true > assembler(ori,bases,bc,force,materialMatrix);
assembler.setPointLoads(pLoads);
// Function for the Jacobian
{
assembler.constructSolution(x,def);
ThinShellAssemblerStatus status = assembler.assembleMatrix(def);
m = assembler.matrix();
};
// Function for the Residual
{
assembler.constructSolution(x,def);
ThinShellAssemblerStatus status = assembler.assembleVector(def);
v = assembler.rhs();
};
assembler.assemble();
gsSparseMatrix<> K = assembler.matrix();
gsVector<> F = assembler.rhs();
gsStaticNewton<real_t> solver(K,F,Jacobian,Residual);
solver.options().setInt("verbose",2);
solver.initialize();
gsInfo<<"Solving system with "<<assembler.numDofs()<<" DoFs\n";
gsStatus status = solver.solve();
GISMO_ASSERT(status==gsStatus::Success,"Solver failed");
gsVector<> solVector = solver.solution();
gsMultiPatch<> displ = assembler.constructDisplacement(solVector);
gsMultiPatch<> def = assembler.constructSolution(solVector);
// Evaluate the solution on a reference point (parametric coordinates)
// The reference points are stored column-wise
gsMatrix<> refPoint(2,1);
refPoint<<0.5,0.5;
// Compute the values
gsVector<> physpoint = def.patch(0).eval(refPoint);
gsVector<> refVals = displ.patch(0).eval(refPoint);
// gsInfo << "Displacement at reference point: "<<numVal<<"\n";
gsInfo << "Displacement at reference point ("
<<ori.patch(0).eval(refPoint).transpose()<<"): "
<<": "<<refVals.transpose()<<"\n";
// ! [Export visualization in ParaView]
if (plot)
{
// Plot the displacements on the deformed geometry
gsField<> solField(def, displ);
gsInfo<<"Plotting in Paraview...\n";
gsWriteParaview<>( solField, "Deformation", 1000, true);
// Plot the membrane Von-Mises stresses on the geometry
assembler.constructStress(def,VMm,stress_type::von_mises_membrane);
gsField<> membraneStress(def,VMm, true);
gsWriteParaview(membraneStress,"MembraneStress",1000);
}
// ! [Export visualization in ParaView]
return EXIT_SUCCESS;
#else
GISMO_ERROR("The tutorial needs to be compiled with gsKLShell enabled");
return EXIT_FAILED;
#endif
}// end main
Class containing a set of boundary conditions.
Definition gsBoundaryConditions.h:342
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
Class defining a globally constant function.
Definition gsConstantFunction.h:34
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
memory::unique_ptr< gsMaterialMatrixBase > uPtr
Unique pointer for gsGeometry.
Definition gsMaterialMatrixBase.h:44
A matrix with arbitrary coefficient type and fixed or dynamic size.
Definition gsMatrix.h:41
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
bool computeTopology(T tol=1e-4, bool cornersOnly=false, bool tjunctions=false)
Attempt to compute interfaces and boundaries automatically.
Definition gsMultiPatch.hpp:377
gsGeometry< T > & patch(size_t i) const
Return the i-th patch.
Definition gsMultiPatch.h:292
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
Class which holds a list of parameters/options, and provides easy access to them.
Definition gsOptionList.h:33
void addInt(const std::string &label, const std::string &desc, const index_t &value)
Adds a option named label, with description desc and value value.
Definition gsOptionList.cpp:201
A function depending on an index i, typically referring to a patch/sub-domain. On each patch a differ...
Definition gsPiecewiseFunction.h:29
Class containing a set of points on a multi-patch isogeometric domain, together with boundary conditi...
Definition gsPointLoads.h:65
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
Static solver using a newton method.
Definition gsStaticNewton.h:30
Assembles the system matrix and vectors for 2D and 3D shell problems, including geometric nonlinearit...
Definition gsThinShellAssembler.h:77
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.
#define index_t
Definition gsConfig.h:32
#define GISMO_ERROR(message)
Definition gsDebug.h:118
Static solver using a newton method.
Class providing Structural Analysis Utilities.
The G+Smo namespace, containing all definitions for the library.
@ von_mises_membrane
compute only von Mises stress
Definition gsThinShellFunctions.h:42