// chunk_size>1, then this isn't
// necessarily true
bool exc_thrown = false;
- double d;
try
{
- d = m(i,j);
+ m(i,j);
}
catch (const std::exception &)
{
deallog << prefix << ' ' << "Pre-refinement: " << tria.n_active_cells() << std::endl;
}
-
+
template <int dim, int spacedim>
void
post_refinement_notification (const std::string &prefix,
deallog << prefix << ' ' << "Post-refinement: " << tria.n_active_cells() << std::endl;
}
-
+
template <int dim, int spacedim>
void
copy_notification (const std::string &prefix,
<< new_tria.n_active_cells() << std::endl;
}
-
+
template <int dim, int spacedim>
void
create_notification (const std::string &prefix,
std_cxx1x::_1,
std_cxx1x::cref(tria_2)))
};
-
-
+
+
// this should print the create note
GridGenerator::hyper_cube(tria_1);
connections_1[i].disconnect ();
tria_1.refine_global (2);
+
+ (void)connections_2;
}
deallog << prefix << ' ' << "Pre-refinement: " << tria.n_active_cells() << std::endl;
}
-
+
template <int dim, int spacedim>
void
post_refinement_notification (const std::string &prefix,
deallog << prefix << ' ' << "Post-refinement: " << tria.n_active_cells() << std::endl;
}
-
+
template <int dim, int spacedim>
void
copy_notification (const std::string &prefix,
<< new_tria.n_active_cells() << std::endl;
}
-
+
template <int dim, int spacedim>
void
create_notification (const std::string &prefix,
"tria_2",
std_cxx1x::cref(tria_2)))
};
-
-
+
+
// this should print the create note
GridGenerator::hyper_cube(tria_1);
// and now really nothing
connections_1[4].disconnect ();
tria_1.refine_global (1);
+
+ // avoid compiler warning
+ (void)connections_2;
}
GridGenerator::hyper_cube(tr, 0., 1.);
DoFHandler<dim> dof(tr);
- typename DoFHandler<dim>::cell_iterator c = dof.begin();
dof.distribute_dofs(fe_rt);
QTrapez<1> q_trapez;
p1(d) = 0;
p2(d) = (d == 0) ? 2.0 : 1.0;
sub_div.push_back ( (d == 0) ? 2 : 1);
- }
+ }
GridGenerator::subdivided_hyper_rectangle (tria, sub_div, p1, p2, true);
// Refine the first cell.
tria.begin_active ()->set_refine_flag ();
tria.execute_coarsening_and_refinement ();
-
+
return (0);
}
cell->set_active_fe_index (fe_indx);
++fe_indx;
}
-
+
// Distribute DoFs;
dof_handler.distribute_dofs (fe_coll);
deallog << "DoFs: " << dof_handler.n_dofs () << std::endl;
-
+
// Create the constraints.
ConstraintMatrix constraint_matrix;
-
+
DoFTools::make_hanging_node_constraints (dof_handler,
constraint_matrix);
// Output the constraints
- constraint_matrix.print (deallog.get_file_stream ());
+ constraint_matrix.print (deallog.get_file_stream ());
}
// active_fe_indices to
// the different cells.
DoFHandler<dim> dof_handler (tria);
- typename DoFHandler<dim>::active_cell_iterator cell = dof_handler.begin_active (),
- endc = dof_handler.end ();
-
+
// Distribute DoFs;
dof_handler.distribute_dofs (fe);
deallog << "DoFs: " << dof_handler.n_dofs () << std::endl;
-
+
// Create the constraints.
ConstraintMatrix constraint_matrix;
-
+
DoFTools::make_hanging_node_constraints (dof_handler,
constraint_matrix);
constraint_matrix.print (deallog.get_file_stream ());
}
-int main ()
+int main ()
{
std::ofstream logfile("hp_hanging_nodes_01/output");
logfile.precision(2);
-
+
deallog.attach(logfile);
deallog.depth_console(0);
deallog.threshold_double(1.e-10);
-
+
FE_Q<2> fe_1 (1);
FE_Q<2> fe_2 (2);
FE_Q<2> fe_3 (3);
fe_coll2.push_back (fe_2);
fe_coll2.push_back (fe_2);
- fe_coll2.push_back (fe_3);
-
+ fe_coll2.push_back (fe_3);
+
test_constraints<2> (fe_coll2);
test_constraints_old<2> (fe_1);
void test()
{
unsigned int myid = Utilities::System::get_this_mpi_process (MPI_COMM_WORLD);
- unsigned int numproc = Utilities::System::get_n_mpi_processes (MPI_COMM_WORLD);
parallel::distributed::Triangulation<dim> tr(MPI_COMM_WORLD);
x_rel = x;
//l2_norm() not possible for ghosted vectors...
- double a=0;//x_test.l2_norm();
- double b=0;//x_rel.l2_norm();
+ //double a=0;//x_test.l2_norm();
+ //double b=0;//x_rel.l2_norm();
/* if (myid==0)
deallog << a << " vs " << b << std::endl;
void test()
{
unsigned int myid = Utilities::System::get_this_mpi_process (MPI_COMM_WORLD);
- unsigned int numproc = Utilities::System::get_n_mpi_processes (MPI_COMM_WORLD);
// create a mesh so that all but one
// processor are empty
int main(int argc, char *argv[])
{
#ifdef DEAL_II_COMPILER_SUPPORTS_MPI
- MPI_Init (&argc,&argv);
+ Utilities::System::MPI_InitFinalize mpi (argc, argv);
#else
(void)argc;
(void)argv;
+ compile_time_error;
#endif
unsigned int myid = Utilities::System::get_this_mpi_process (MPI_COMM_WORLD);
test<2>();
test<3>();
}
-
-#ifdef DEAL_II_COMPILER_SUPPORTS_MPI
- MPI_Finalize();
-#endif
}
void test()
{
unsigned int myid = Utilities::System::get_this_mpi_process (MPI_COMM_WORLD);
- unsigned int numproc = Utilities::System::get_n_mpi_processes (MPI_COMM_WORLD);
parallel::distributed::Triangulation<dim> tr(MPI_COMM_WORLD);
void test()
{
unsigned int myid = Utilities::System::get_this_mpi_process (MPI_COMM_WORLD);
- unsigned int numproc = Utilities::System::get_n_mpi_processes (MPI_COMM_WORLD);
parallel::distributed::Triangulation<dim> tr(MPI_COMM_WORLD);
const double R0 = 6371000.-2890000.;
const double R1 = 6371000.- 35000.;
-
+
GridGenerator::hyper_shell (tr,
Point<dim>(),
R0,
static HyperShellBoundary<dim> boundary;
tr.set_boundary (0, boundary);
tr.set_boundary (1, boundary);
-
+
tr.refine_global (1);
for (unsigned int step=0; step<20;++step)
{
tr.execute_coarsening_and_refinement ();
}
-
+
DoFHandler<dim> dofh(tr);
static FESystem<dim> fe (FE_Q<dim>(1+1), dim,
dofh.distribute_dofs (fe);
IndexSet owned_set = dofh.locally_owned_dofs();
-
+
IndexSet dof_set;
DoFTools::extract_locally_active_dofs (dofh, dof_set);
x_rel.reinit(relevant_set, MPI_COMM_WORLD);
x_rel = 0;
x_rel.compress();
-
+
ConstraintMatrix cm(relevant_set);
DoFTools::make_hanging_node_constraints (dofh, cm);
std::vector<bool> velocity_mask (dim+1, true);
-
+
velocity_mask[dim] = false;
-
+
VectorTools::interpolate_boundary_values (dofh,
0,
ZeroFunction<dim>(dim+1),
cm,
- velocity_mask);
+ velocity_mask);
std::set<unsigned char> no_normal_flux_boundaries;
no_normal_flux_boundaries.insert (1);
-
+
VectorTools::compute_no_normal_flux_constraints (dofh, 0,
no_normal_flux_boundaries,
cm);
-
+
cm.close ();
cm.distribute(x);
for (unsigned int i=0; i<dim; ++i)
data_component_interpretation[i]
= DataComponentInterpretation::component_is_part_of_vector;
-
+
data_out.add_data_vector(x_rel, joint_solution_names,
DataOut<dim>::type_dof_data,
data_component_interpretation);
TrilinosWrappers::Vector x_dub;
x_dub.reinit(dof_set.size());
x_dub = x_rel;
-
+
if (myid==0)
{
std::ofstream file((std::string("p4est_2d_constraintmatrix_03/dat.") + Utilities::int_to_string(myid)).c_str());
file << "**** proc " << myid << std::endl;
x_dub.print(file);
}
-
+
MPI_Barrier(MPI_COMM_WORLD);
-
+
if (myid==0)
{
cat_file((std::string("p4est_2d_constraintmatrix_03/dat.") + Utilities::int_to_string(0)).c_str());
TemperatureInitialValues<dim>::value (const Point<dim> &p,
const unsigned int) const
{
- const double r = p.norm();
- const double h = R1-R0;
-
- const double s = (r-R0)/h;
-// see http://www.wolframalpha.com/input/?i=plot+(sqrt(x^2%2By^2)*0.95%2B0.05*sin(6*atan2(x,y))),+x%3D-1+to+1,+y%3D-1+to+1
-
- double s_mod = s*0.95 + 0.05*sin(6.0*atan2(p(0),p(1)));
-//alternative: http://www.wolframalpha.com/input/?i=plot+atan((sqrt(x^2%2By^2)*0.95%2B0.05*sin(6*atan2(x,y))-0.5)*10)/pi%2B0.5,+x%3D-1+to+1,+y%3D-1+to+1
-// s_mod = atan((s_mod-0.5)*10.0)/dealii::numbers::PI+0.5;
-
-// return T1+(T0-T1)*(1.0-s_mod);
-
- //old:
-// return T1+(T0-T1)*((1-s)*(1-s)); //old
-// return T1+(T0-T1)*((1-s)); //linear
return p(0)*T1+p(1)*(T0-T1); //simple
}
template<int dim>
void test()
{
- unsigned int myid = Utilities::System::get_this_mpi_process (MPI_COMM_WORLD);
- unsigned int numproc = Utilities::System::get_n_mpi_processes (MPI_COMM_WORLD);
-
parallel::distributed::Triangulation<dim> tr(MPI_COMM_WORLD);
// GridGenerator::hyper_cube(tr);
-
-
+
+
GridGenerator::hyper_shell (tr,
Point<dim>(),
R0,
static HyperShellBoundary<dim> boundary;
// tr.set_boundary (0, boundary);
// tr.set_boundary (1, boundary);
-
+
tr.refine_global (3);
if (1)
for (unsigned int step=0; step<5;++step)
typename Triangulation<dim>::active_cell_iterator
cell = tr.begin_active(),
endc = tr.end();
-
+
for (; cell!=endc; ++cell)
if (std::rand()%42==1)
cell->set_refine_flag ();
-
+
tr.execute_coarsening_and_refinement ();
}
-
+
DoFHandler<dim> dofh(tr);
static FE_Q<dim> fe(2);
-
+
dofh.distribute_dofs (fe);
IndexSet owned_set = dofh.locally_owned_dofs();
-
+
IndexSet dof_set;
DoFTools::extract_locally_active_dofs (dofh, dof_set);
TrilinosWrappers::MPI::Vector x_rel;
x_rel.reinit(relevant_set, MPI_COMM_WORLD);
x_rel = x;
-
+
for (unsigned int steps=0;steps<3;++steps)
- {
+ {
{
typename Triangulation<dim>::active_cell_iterator
cell = tr.begin_active(),
endc = tr.end();
-
+
for (; cell!=endc; ++cell)
if (!cell->is_artificial() && !cell->is_ghost())
{
cell->set_refine_flag ();
else if (std::rand()%7==1)
cell->set_coarsen_flag ();
- }
+ }
}
for (typename Triangulation<dim>::cell_iterator
cell = tr.begin();
{
if (!cell->has_children())
continue;
-
+
bool coarsen_me = false;
for (unsigned int i=0;i<cell->n_children();++i)
if (cell->child(i)->coarsen_flag_set())
-
+
parallel::distributed::SolutionTransfer<dim,TrilinosWrappers::MPI::Vector>
trans(dofh);
tr.prepare_coarsening_and_refinement();
-
+
trans.prepare_for_coarsening_and_refinement(x_rel);
-
- tr.execute_coarsening_and_refinement ();
+
+ tr.execute_coarsening_and_refinement ();
static FE_Q<dim> fe(1);
-
+
dofh.distribute_dofs (fe);
owned_set = dofh.locally_owned_dofs();
-
+
DoFTools::extract_locally_active_dofs (dofh, dof_set);
DoFTools::extract_locally_relevant_dofs (dofh, relevant_set);
x.reinit(owned_set, MPI_COMM_WORLD);
trans.interpolate(x);
-
+
x_rel.reinit(relevant_set, MPI_COMM_WORLD);
x_rel = 0;
x_rel.compress();
-
+
ConstraintMatrix cm(relevant_set);
DoFTools::make_hanging_node_constraints (dofh, cm);
/* std::vector<bool> velocity_mask (dim+1, true);
-
+
velocity_mask[dim] = false;
-
+
VectorTools::interpolate_boundary_values (dofh,
0,
ZeroFunction<dim>(1),
TrilinosWrappers::MPI::Vector x_ref;
x_ref.reinit(owned_set, MPI_COMM_WORLD);
-
+
VectorTools::interpolate(dofh,
TemperatureInitialValues<dim>(),
x_ref);
x_ref.compress();
-
+
x_ref -= x;
double err = x_ref.linfty_norm();
if (err>1.0e-12)
if (Utilities::System::get_this_mpi_process (MPI_COMM_WORLD) == 0)
deallog << "err:" << err << std::endl;
-
+
// x_rel=x_ref; //uncomment to output error
-
+
std::vector<std::string> solution_names(1,"T");
-
+
FilteredDataOut<dim> data_out (tr.locally_owned_subdomain());
data_out.attach_dof_handler (dofh);
-
+
data_out.add_data_vector(x_rel, solution_names);
-
+
data_out.build_patches (1);
const std::string filename = ("p4est_2d_constraintmatrix_04/solution." +
Utilities::int_to_string
".d2");
std::ofstream output (filename.c_str());
data_out.write_deal_II_intermediate (output);
-
+
tr.set_boundary (0);
tr.set_boundary (1);
if (Utilities::System::get_this_mpi_process (MPI_COMM_WORLD) == 0)
template<int dim>
void test()
{
- unsigned int myid = Utilities::System::get_this_mpi_process (MPI_COMM_WORLD);
- unsigned int numproc = Utilities::System::get_n_mpi_processes (MPI_COMM_WORLD);
-
parallel::distributed::Triangulation<dim> tr(MPI_COMM_WORLD);
GridGenerator::hyper_cube(tr);
TemperatureInitialValues<dim>::value (const Point<dim> &p,
const unsigned int) const
{
- const double r = p.norm();
- const double h = R1-R0;
-
- const double s = (r-R0)/h;
-// see http://www.wolframalpha.com/input/?i=plot+(sqrt(x^2%2By^2)*0.95%2B0.05*sin(6*atan2(x,y))),+x%3D-1+to+1,+y%3D-1+to+1
-
- double s_mod = s*0.95 + 0.05*sin(6.0*atan2(p(0),p(1)));
-//alternative: http://www.wolframalpha.com/input/?i=plot+atan((sqrt(x^2%2By^2)*0.95%2B0.05*sin(6*atan2(x,y))-0.5)*10)/pi%2B0.5,+x%3D-1+to+1,+y%3D-1+to+1
-// s_mod = atan((s_mod-0.5)*10.0)/dealii::numbers::PI+0.5;
-
-// return T1+(T0-T1)*(1.0-s_mod);
-
- //old:
-// return T1+(T0-T1)*((1-s)*(1-s)); //old
-// return T1+(T0-T1)*((1-s)); //linear
return p(0)*T1+p(1)*(T0-T1); //simple
}
template<int dim>
void test()
{
- unsigned int myid = Utilities::System::get_this_mpi_process (MPI_COMM_WORLD);
- unsigned int numproc = Utilities::System::get_n_mpi_processes (MPI_COMM_WORLD);
-
parallel::distributed::Triangulation<dim> tr(MPI_COMM_WORLD);