int main(int argc, char *argv[])
{
bool plot = false;
gsCmdLine cmd(
"Example for solving the biharmonic problem.");
cmd.addInt("r", "refine", "Number of refinement steps", numRefine);
cmd.addInt("p", "degree", "Polynomial degree", numDegree);
cmd.addSwitch( "plot", "Plot result in ParaView format", plot );
try { cmd.getValues(argc,argv); } catch (int rv) { return rv; }
dirichlet::strategy dirStrategy = dirichlet::elimination;
iFace::strategy intStrategy = iFace::glue;
gsFunctionExpr<> source (
"256*pi*pi*pi*pi*(4*cos(4*pi*x)*cos(4*pi*y) - cos(4*pi*x) - cos(4*pi*y))",2);
gsFunctionExpr<> laplace (
"-16*pi*pi*(2*cos(4*pi*x)*cos(4*pi*y) - cos(4*pi*x) - cos(4*pi*y))",2);
"-4*pi*(cos(4*pi*x) - 1)*sin(4*pi*y)",2);
"-16*pi^2*(cos(4*pi*x) - 1)*cos(4*pi*y)",
" 16*pi^2*sin(4*pi*x)*sin(4*pi*y)", 2);
gsFunctionWithDerivatives<real_t> solution(solVal, sol1der, sol2der);
basis.degreeElevate(1,0);
for (int i = 0; i < numDegree; ++i)
basis.degreeElevate();
for (int i = 0; i < numRefine; ++i)
basis.uniformRefine();
dirStrategy, intStrategy);
gsInfo<<
"Assembling..." <<
"\n";
BiharmonicAssembler.assemble();
gsInfo<<
"Solving with direct solver, "<< BiharmonicAssembler.numDofs()<<
" DoFs..."<<
"\n";
gsSparseSolver<real_t>::LU solver;
solver.analyzePattern(BiharmonicAssembler.matrix() );
solver.factorize(BiharmonicAssembler.matrix());
gsMatrix<> solVector= solver.solve(BiharmonicAssembler.rhs());
BiharmonicAssembler.constructSolution(solVector, mpsol);
gsField<> solField(BiharmonicAssembler.patches(), mpsol);
real_t errorH2Semi = solField.distanceH2(solution, false);
real_t errorH1Semi = solField.distanceH1(solution, false);
real_t errorL2 = solField.distanceL2(solution, false);
real_t errorH1 = math::sqrt(errorH1Semi*errorH1Semi + errorL2*errorL2);
real_t errorH2 = math::sqrt(errorH2Semi*errorH2Semi + errorH1Semi*errorH1Semi + errorL2*errorL2);
gsInfo <<
"The L2 error of the solution is : " << errorL2 <<
"\n";
gsInfo <<
"The H1 error of the solution is : " << errorH1 <<
"\n";
gsInfo <<
"The H2 error of the solution is : " << errorH2 <<
"\n";
if (plot)
{
gsInfo<<
"Plotting in ParaView...\n";
gsWriteParaview<>(solField, "Biharmonic2d", 5000);
const gsField<> exact( geo, solution,
false );
gsWriteParaview<>( exact, "Biharmonic2d_exact", 5000);
}
else
gsInfo <<
"Done. No output created, re-run with --plot to get a ParaView "
"file containing the solution.\n";
return 0;
}
Implementation of a homogeneous Biharmonic Assembler.
Definition gsBiharmonicAssembler.h:37
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
Class for command-line argument parsing.
Definition gsCmdLine.h:57
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
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
Main header to be included by clients using the G+Smo library.
#define index_t
Definition gsConfig.h:32
#define gsInfo
Definition gsDebug.h:43
The G+Smo namespace, containing all definitions for the library.
Provides assembler for a homogeneous Biharmonic equation.
@ dirichlet
Dirichlet type.
Definition gsBoundaryConditions.h:31
@ neumann
Neumann type.
Definition gsBoundaryConditions.h:33
Class gsNurbsCreator provides some simple examples of Nurbs Geometries.
Definition gsNurbsCreator.h:37