Skip to content
58 changes: 58 additions & 0 deletions include/boundary_values.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#ifndef __boundary_values_h
#define __boundary_values_h

#include <deal.II/base/function.h>
#include <deal.II/lac/vector.h>
#include "heart_fe.h"

using namespace dealii;

template <int dim>
class BoundaryValues : public Function<dim>
{
public:
BoundaryValues (int color, bool derivative=false)
:
Function<dim>(dim),
color(color),
derivative(derivative)
{}
BoundaryValues (int color,
double timestep,
double dt,
bool side,
int degree,
bool derivative=false)
:
Function<dim>(dim),
color(color),
timestep(timestep),
dt(dt),
heartstep(timestep/heartinterval),
derivative(derivative),
heart(side, degree)
{}

virtual double value (const Point<dim> &p,
const unsigned int component = 0) const;
virtual void vector_value (const Point<dim> &p,
Vector<double> &value) const;
private:
int color;
double timestep;
double dt;
double heartinterval = 0.005;
int heartstep;// = timestep / heartinterval;
bool derivative;
Heart<2,3> heart;
void transform_to_polar_coord(const Point<3> &p,
double rot,
double &angle,
double &height) const;
void swap_coord(Point<3> &p) const;
void get_heartdelta (const Point<dim> &p, Vector<double> &value, int heartstep) const;
void get_values (const Point<dim> &p, Vector<double> &value) const;
void get_values_dt (const Point<dim> &p, Vector<double> &value) const;
};

#endif
60 changes: 60 additions & 0 deletions include/elastic_problem.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#ifndef __elastic_problem_h
#define __elastic_problem_h

#include <deal.II/base/quadrature_lib.h>
#include <deal.II/base/function.h>
#include <deal.II/base/logstream.h>
#include <deal.II/lac/vector.h>
#include <deal.II/lac/full_matrix.h>
#include <deal.II/lac/sparse_matrix.h>
#include <deal.II/lac/dynamic_sparsity_pattern.h>
#include <deal.II/lac/solver_cg.h>
#include <deal.II/lac/precondition.h>
#include <deal.II/lac/constraint_matrix.h>
#include <deal.II/grid/tria.h>
#include <deal.II/grid/grid_generator.h>
#include <deal.II/grid/grid_refinement.h>
#include <deal.II/grid/grid_tools.h>
#include <deal.II/grid/manifold_lib.h>
#include <deal.II/grid/tria_accessor.h>
#include <deal.II/grid/tria_iterator.h>
#include <deal.II/dofs/dof_handler.h>
#include <deal.II/dofs/dof_accessor.h>
#include <deal.II/dofs/dof_tools.h>
#include <deal.II/fe/fe_values.h>
#include <deal.II/numerics/vector_tools.h>
#include <deal.II/numerics/matrix_tools.h>
#include <deal.II/numerics/data_out.h>
#include <deal.II/numerics/error_estimator.h>
#include <deal.II/fe/fe_system.h>
#include <deal.II/fe/fe_q.h>

using namespace dealii;


template <int dim>
class ElasticProblem
{
public:
ElasticProblem ();
ElasticProblem (double timestep, double dt);
~ElasticProblem ();
void run (Triangulation<dim> &external_tria);
private:
void setup_system ();
void assemble_system ();
void solve ();
void refine_grid ();
Triangulation<dim> triangulation;
DoFHandler<dim> dof_handler;
FESystem<dim> fe;
ConstraintMatrix hanging_node_constraints;
SparsityPattern sparsity_pattern;
SparseMatrix<double> system_matrix;
Vector<double> solution;
Vector<double> system_rhs;
double timestep;
double dt;
};

#endif
33 changes: 33 additions & 0 deletions include/heart_fe.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#ifndef __heart_fe_h
#define __heart_fe_h

#include <deal.II/grid/tria.h>
#include <deal.II/fe/fe_system.h>
#include <deal.II/lac/vector.h>
#include <deal.II/dofs/dof_handler.h>

using namespace dealii;

template <int dim,int spacedim>
class Heart
{
public:
Heart ();
Heart (bool, const int);
Point<spacedim> push_forward (const Point<dim>, const int) const;

private:
void reinit_data ();
void setup_system ();
void run_side ();
void run_bottom ();

Triangulation<dim> triangulation;
FESystem<dim> fe;
DoFHandler<dim> dof_handler;
std::vector<Vector<double> > solution;

bool side;
};

#endif
4 changes: 2 additions & 2 deletions include/interfaces/stokes.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

#include <deal.II/lac/solver_cg.h>
#include <deal2lkit/sacado_tools.h>
#include <deal2lkit/parsed_preconditioner_amg.h>
#include <deal2lkit/parsed_preconditioner_jacobi.h>
#include <deal2lkit/parsed_preconditioner/amg.h>
#include <deal2lkit/parsed_preconditioner/jacobi.h>

using namespace SacadoTools;

Expand Down
199 changes: 199 additions & 0 deletions main/heart_stokes.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
#include "interfaces/stokes.h"
#include "pidomus.h"

#include "deal.II/base/numbers.h"

#include "Teuchos_CommandLineProcessor.hpp"
#include "Teuchos_GlobalMPISession.hpp"
#include "Teuchos_oblackholestream.hpp"
#include "Teuchos_StandardCatchMacros.hpp"
#include "Teuchos_Version.hpp"

#include "mpi.h"
#include <iostream>
#include <string>

#include "elastic_problem.h"


void print_status( std::string name,
std::string prm_file,
int dim,
// int spacedim,
int n_threads,
const MPI_Comm &comm,
bool check_prm);


int main (int argc, char *argv[])
{
using namespace dealii;
using namespace deal2lkit;

Teuchos::CommandLineProcessor My_CLP;
My_CLP.setDocString(
" ______ ___ ____ _ __________ \n"
" | _ \\ | \\/ | | | / ______ \\ \n"
" ______________| | | |____| . . | |_| \\ `--.___| | \n"
" |__ __ ______| | | / _ \\| |\\/| | |_| |`--. \\____/ \n"
" | | | | | |/ | (_) | | | | |_| /\\__/ / \n"
" |_| |_| |___/ \\___/\\_| |_/\\___/\\____/ \n"
);

std::string pde_name="stokes";
//My_CLP.setOption("pde", &pde_name, "name of the PDE (stokes, NS for navier stokes, or ALE for ALE navier stokes)");

// int spacedim = 2;
// My_CLP.setOption("spacedim", &spacedim, "dimensione of the whole space");

int dim = 3;
//My_CLP.setOption("dim", &dim, "dimension of the problem");

int n_threads = 0;
My_CLP.setOption("n_threads", &n_threads, "number of threads");

std::string prm_file=pde_name+".prm";
My_CLP.setOption("prm", &prm_file, "name of the parameter file");

bool check_prm = false;
My_CLP.setOption("check","no-check", &check_prm, "wait for a key press before starting the run");

// My_CLP.recogniseAllOptions(true);
My_CLP.throwExceptions(false);

Teuchos::CommandLineProcessor::EParseCommandLineReturn
parseReturn= My_CLP.parse( argc, argv );

if ( parseReturn == Teuchos::CommandLineProcessor::PARSE_HELP_PRINTED )
{
return 0;
}
if ( parseReturn != Teuchos::CommandLineProcessor::PARSE_SUCCESSFUL )
{
return 1; // Error!
}

Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv,
n_threads == 0 ? numbers::invalid_unsigned_int : n_threads);

const MPI_Comm &comm = MPI_COMM_WORLD;

Teuchos::oblackholestream blackhole;
std::ostream &out = ( Utilities::MPI::this_mpi_process(comm) == 0 ? std::cout : blackhole );


std::string string_pde_name="Stokes";


My_CLP.printHelpMessage(argv[0], out);

// deallog.depth_console (0);
try
{
print_status( string_pde_name+" Equations",
prm_file,
dim,
// spacedim,
n_threads,
comm,
check_prm);

StokesInterface<3,3,LATrilinos> interface;
piDoMUS<3,3,LATrilinos> stokes ("pi-DoMUS",interface);
ParameterAcceptor::initialize(prm_file, pde_name+"_used.prm");


stokes.lambdas.output_step = [&] (const double t,
const typename LATrilinos::VectorType &/*sol*/,
const typename LATrilinos::VectorType &/*sol_dot*/,
const unsigned int /*step_number*/)
{
// auto &dof = interface.get_dof_handler();
auto &tria = const_cast<parallel::distributed::Triangulation<3,3>&>
(interface.get_triangulation());
double dt = interface.get_timestep();
if (dt != dt) // check if dt is NaN
dt = 1;

ElasticProblem<3> elastic_problem(t, dt);
elastic_problem.run(tria);
};

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get the following compiling error, which I don't understand:

main/heart_stokes.cc:116:31: error: binding of reference to type 'Triangulation<[2 * ...]>' to a value of type 'Triangulation<[2 * ...]>' drops qualifiers
          elastic_problem.run(tria);
                              ^~~~
include/elastic_problem.h:42:33: note: passing argument to parameter 'external_tria' here
  void run (Triangulation<dim> &external_tria);
                                ^

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see PR wil2810#1

stokes.run ();


out << std::endl;
}
catch (std::exception &exc)
{
std::cerr << std::endl << std::endl
<< "----------------------------------------------------"
<< std::endl;
std::cerr << "Exception on processing: " << std::endl
<< exc.what() << std::endl
<< "Aborting!" << std::endl
<< "----------------------------------------------------"
<< std::endl;

return 1;
}
catch (...)
{
std::cerr << std::endl << std::endl
<< "----------------------------------------------------"
<< std::endl;
std::cerr << "Unknown exception!" << std::endl
<< "Aborting!" << std::endl
<< "----------------------------------------------------"
<< std::endl;
return 1;
}

return 0;
}

void print_status( std::string name,
std::string prm_file,
int dim,
// int spacedim,
int n_threads,
const MPI_Comm &comm,
bool check_prm)
{
int numprocs = Utilities::MPI::n_mpi_processes(comm);
// int myid = Utilities::MPI::this_mpi_process(comm);

Teuchos::oblackholestream blackhole;
std::ostream &out = ( Utilities::MPI::this_mpi_process(comm) == 0 ? std::cout : blackhole );


out << std::endl
<< "============================================================="
<< std::endl
<< " Name: " << name
<< std::endl
<< " Prm file: " << prm_file
<< std::endl
<< "n threads: " << n_threads
<< std::endl
<< " process: " << getpid()
<< std::endl
<< " proc.tot: " << numprocs
<< std::endl
// << " spacedim: " << spacedim
// << std::endl
<< " dim: " << dim
// << std::endl
// << " codim: " << spacedim-dim
<< std::endl;
if (check_prm)
{
out<< "-------------------------------------------------------------"
<< std::endl;
out << "Press [Enter] key to start...";
if (std::cin.get() == '\n') {};
}
out << "============================================================="
<<std::endl<<std::endl;

}
Loading