using namespace gismo;
int main(
int argc,
char *argv[])
{
bool plot = false;
cmd.addSwitch("plot", "Plot the result in ParaView.", plot);
try { cmd.getValues(argc,argv); } catch (int rv) { return rv; }
gsInfo<<"Source function is: "<< f << "\n";
patches.computeTopology();
int numRefine = 2;
int numElevate = 0;
if ( numElevate > -1 )
{
int tmp = refine_bases.maxDegree(0);
for (
short_t j = 1; j < patches.parDim(); ++j )
if ( tmp < refine_bases.maxDegree(j) )
tmp = refine_bases.maxDegree(j);
tmp += numElevate;
refine_bases.setDegree(tmp);
}
for (int i = 0; i < numRefine; ++i)
refine_bases.uniformRefine();
real_t theta = 0.5;
stationary.options().setInt("DirichletStrategy", dirichlet::elimination);
stationary.options().setInt("InterfaceStrategy", iFace::glue);
assembler.setTheta(theta);
gsSparseSolver<>::CGDiagonal solver;
gsInfo<<"Assembling mass and stiffness...\n";
real_t endTime = 0.1;
int numSteps = 40;
Sol.setZero(ndof, 1);
real_t Dt = endTime / numSteps ;
const std::string baseName("heat_eq_solution");
collection.options().setInt("numPoints", 1000);
collection.options().setInt("precision", 5);
if ( plot )
{
gsField<> sol = stationary.constructSolution(Sol);
collection.newTimeStep(&patches);
collection.addField(sol, "Temperature");
collection.saveTimeStep();
}
for ( int i = 1; i<=numSteps; ++i)
{
assembler.nextTimeStep(Sol, Dt);
gsInfo<<"Solving timestep "<< i*Dt<<".\n";
Sol = solver.compute( assembler.
matrix() ).solve( assembler.
rhs() );
gsField<> sol = stationary.constructSolution(Sol);
if ( plot )
{
collection.newTimeStep(&patches);
collection.addField(sol, "Temperature");
collection.saveTimeStep();
}
}
if ( plot )
{
collection.save();
}
else
gsInfo << "Done. No output created, re-run with --plot to get a ParaView "
"file containing the solution.\n";
return EXIT_SUCCESS;
}