#include "Sundance.h"
int main(int argc, void** argv)
{
MPIComm::init(&argc, &argv);
try
{
Timer::start();
MeshReader reader = new ShewchukMeshReader("tBird.1");
Mesh mesh = reader.getMesh();
Expr x = new CoordExpr(0);
Expr y = new CoordExpr(1);
CellSet boundary = new BoundaryCellSet();
CellSet leftInlet = boundary.subset( x < 0.0 && y == -7.0 );
CellSet rightInlet = boundary.subset( x > 0.0 && y == -7.0 );
CellSet topOutlet = boundary.subset( x == -4.0 );
CellSet bottomOutlet = boundary.subset( y == -10.0 );
CellSet inflow = leftInlet + rightInlet;
CellSet outflow = topOutlet + bottomOutlet;
CellSet walls = boundary - inflow - outflow;
CellSet bottomLeftWall = walls.subset( x >= -6.5 && y < 1.0 && x < 0.0 );
CellSet bottomRightWall = walls.subset( x <= 6.5 && y < 1.0 && x > 0.0 );
CellSet topLeftWall = walls.subset( x == -7.0
|| (x < 0.0 && y > 1.0 && y < 6.0) );
CellSet topRightWall = walls.subset( y == 7.0 || x==7.0 || x==2.0
|| (x > 0.0 && y==3.0));
Expr v = new TestFunction(new Lagrange(1));
Expr u = new UnknownFunction(new Lagrange(1));
Expr dx = new Derivative(0);
Expr dy = new Derivative(1);
Expr grad = List(dx, dy);
Integral eqn = Integral(-(grad*v)*(grad*u));
EssentialBC bc = EssentialBC(bottomLeftWall, v*u)
&& EssentialBC(topLeftWall, v*(u-1.0))
&& EssentialBC(topRightWall, v*(u-2.0))
&& EssentialBC(bottomRightWall, v*(u-3.0));
TSFPreconditionerFactory precond = new ILUKPreconditionerFactory(2);
TSFLinearSolver solver = new BICGSTABSolver(precond, 1.e-14, 500);
StaticLinearProblem prob(mesh, eqn, bc, v, u,
new PetraVectorType());
Expr solnU = prob.solve(solver);
ofstream of("tBirdHeat.dat");
solnU.matlabDump(of);
Timer::report();
}
catch(exception& e)
{
TSFOut::println(e.what());
}
MPIComm::finalize();
}