78 lines
No EOL
2.5 KiB
C++
78 lines
No EOL
2.5 KiB
C++
#include "geom.h"
|
|
#include "getmatrix.h"
|
|
#include "jacsolve.h"
|
|
#include "userset.h"
|
|
#include "vdop.h"
|
|
|
|
#include <cassert>
|
|
#include <chrono> // timing
|
|
#include <cmath>
|
|
#include <iostream>
|
|
#include <omp.h>
|
|
using namespace std;
|
|
using namespace std::chrono; // timing
|
|
|
|
|
|
int main(int argc, char **argv )
|
|
{
|
|
// generating the mesh
|
|
Mesh const mesh_c("../generate_mesh/coffee_cup.txt", "../generate_mesh/coffee_cup_sd.txt");
|
|
bool ba = mesh_c.checkObtuseAngles();
|
|
if (ba) cout << "mesh corrected" << endl;
|
|
//mesh_c.DebugEdgeBased();
|
|
|
|
//gMesh_Hierarchy ggm(mesh_c, nrefine);
|
|
//const Mesh &mesh = ggm.finest();
|
|
//mesh.Debug();
|
|
//mesh_c.DebugEdgeBased();
|
|
|
|
// ##########################################
|
|
// Assembling
|
|
// ##########################################
|
|
|
|
// Initializing FEM matrix !pattern! (only zero entries now)
|
|
FEM_Matrix SK(mesh_c); // CRS matrix
|
|
//SK.writeBinary("sparseMatrix.bin");
|
|
//SK.Debug();
|
|
|
|
vector<double> fv(SK.Nrows(), 0.0);
|
|
SK.CalculateRHS(fv, [](double x, double y) {return 0;}); // r.h.s.
|
|
|
|
SK.CalculateLaplace_mult(fv); // stiffness matrix
|
|
SK.AddMass_mult(fv); // mass matrix
|
|
SK.ApplyRobinBC_mult(fv, 18.0); // apply Robin bnd
|
|
|
|
SK.CheckRowSum();
|
|
SK.CheckMatrix();
|
|
|
|
// ##########################################
|
|
// Timestepping
|
|
// ##########################################
|
|
|
|
double dt = 1.0; // time step
|
|
int steps = 100; // number of time iterations
|
|
|
|
// Initialize temperature
|
|
vector<double> uv(SK.Nrows(), 0.0); // temperature
|
|
mesh_c.Init_Solution_mult(uv, 0, [](double x, double y) -> double { return 18; }); // mug
|
|
mesh_c.Init_Solution_mult(uv, 1, [](double x, double y) -> double { return 80; }); // fluid
|
|
mesh_c.Init_Solution_mult(uv, 2, [](double x, double y) -> double { return 18; }); // air
|
|
|
|
for (int i = 0; i < steps; ++i)
|
|
{
|
|
// TODO
|
|
}
|
|
|
|
auto t3 = system_clock::now(); // start timer
|
|
//JacobiSolve(SK, fv, uv ); // solve the system of equations
|
|
auto t4 = system_clock::now(); // stop timer
|
|
|
|
auto duration = duration_cast<microseconds>(t4 - t3); // duration in microseconds
|
|
double t_diff = static_cast<double>(duration.count()) / 1e6; // overall duration in seconds
|
|
cout << "JacobiSolve: timing in sec. : " << t_diff << endl;
|
|
|
|
|
|
mesh_c.Visualize(uv);
|
|
|
|
return 0;
|
|
} |