1 #include "../../include/OrderParameterRemapper.h" 8 std::srand(dealii::Utilities::MPI::this_mpi_process(MPI_COMM_WORLD)+1);
10 double value (
const dealii::Point<dim> &p,
const unsigned int component=0)
const{
15 dealii::Point<dim> center0(0.125, 0.125);
16 dealii::Point<dim> center1(1.0, 1.0);
18 if (p.distance(center0) < std::sqrt(2.0)*0.15 or p.distance(center1) < std::sqrt(2.0)*0.15){
38 template <
int dim,
typename T>
41 int thisProc=dealii::Utilities::MPI::this_mpi_process(MPI_COMM_WORLD);
45 std::cout <<
"\nTesting 'OrderParameterRemapper'... " << std::endl;
52 parallel::distributed::Triangulation<dim> triangulation(MPI_COMM_WORLD);
53 GridGenerator::hyper_cube(triangulation);
54 triangulation.refine_global(2);
56 const unsigned int degree = 1;
58 FESystem<dim> fe(FE_Q<dim>(QGaussLobatto<1>(degree+1)),1);
59 DoFHandler<dim> dof_handler(triangulation);
60 dof_handler.distribute_dofs(fe);
61 IndexSet locally_relevant_dofs;
62 DoFTools::extract_locally_relevant_dofs (dof_handler, locally_relevant_dofs);
65 typename MatrixFree<dim,double>::AdditionalData additional_data;
66 #if (DEAL_II_VERSION_MAJOR < 9 && DEAL_II_VERSION_MINOR < 5) 67 additional_data.mpi_communicator = MPI_COMM_WORLD;
69 additional_data.tasks_parallel_scheme = MatrixFree<dim,double>::AdditionalData::partition_partition;
70 additional_data.mapping_update_flags = (update_values | update_gradients | update_JxW_values | update_quadrature_points);
71 QGaussLobatto<1> quadrature (degree+1);
73 ConstraintMatrix constraints;
76 dealii::MatrixFree<dim,double> matrixFreeObject;
77 matrixFreeObject.clear();
78 matrixFreeObject.reinit (dof_handler, constraints, quadrature, additional_data);
82 matrixFreeObject.initialize_dof_vector(*solution_field_0, 0); *solution_field_0 = 0;
87 solution_field_0->update_ghost_values();
91 matrixFreeObject.initialize_dof_vector(*solution_field_1, 0); *solution_field_1 = 0;
96 solution_field_1->update_ghost_values();
98 std::vector<vectorType*> solution_fields;
99 solution_fields.push_back(solution_field_0);
100 solution_fields.push_back(solution_field_1);
104 QGaussLobatto<dim> quadrature2 (degree+1);
107 std::vector<GrainSet<dim>> grain_sets_0;
108 test_object.
calcGrainSets(fe, dof_handler, solution_field_0, 0.1, 1.1, 0, grain_sets_0);
110 std::vector<GrainSet<dim>> grain_sets_1;
111 test_object.
calcGrainSets(fe, dof_handler, solution_field_1, 0.1, 1.1, 1, grain_sets_1);
113 std::vector<GrainSet<dim>> grain_sets = grain_sets_0;
114 grain_sets.insert(grain_sets.end(), grain_sets_1.begin(), grain_sets_1.end());
116 for (
unsigned int g=0; g<grain_sets.size(); g++){
117 grain_sets.at(g).setGrainIndex(g);
120 std::vector<SimplifiedGrainRepresentation<dim>> simplified_grain_representations;
121 for (
unsigned int g=0; g<grain_sets.size(); g++){
123 simplified_grain_representations.push_back(simplified_grain_representation);
126 std::vector<unsigned int> order_parameter_id_list;
127 order_parameter_id_list.push_back(0);
128 order_parameter_id_list.push_back(1);
131 simplified_grain_manipulator.
reassignGrains(simplified_grain_representations, 0.6, order_parameter_id_list);
145 order_parameter_remapper.
remap(simplified_grain_representations, solution_fields, dof_handler, fe.dofs_per_cell, 0.001);
161 for (
unsigned int dof=0; dof<solution_fields.at(0)->size(); ++dof){
162 if (solution_field_0->in_local_range(dof)){
164 if ( std::abs((*solution_fields.at(0))[dof] - 0.0) > 1.0e-10){
166 std::cout <<
"Incorrect value for field 0, dof " << dof <<
": " << (*solution_fields.at(0))[dof] <<
" Expected value is 0" << std::endl;
170 if ( std::abs((*solution_fields.at(0))[dof] - 1.0) > 1.0e-10){
172 std::cout <<
"Incorrect value for field 0, dof " << dof <<
": " << (*solution_fields.at(0))[dof] <<
" Expected value is 1" << std::endl;
178 for (
unsigned int dof=0; dof<solution_fields.at(1)->size(); ++dof){
179 if (solution_field_1->in_local_range(dof)){
181 if ( std::abs((*solution_fields.at(1))[dof] - 1.0) > 1.0e-10){
183 std::cout <<
"Incorrect value for field 1, dof " << dof <<
": " << (*solution_fields.at(1))[dof] <<
" Expected value is 1" << std::endl;
187 if ( std::abs((*solution_fields.at(1))[dof] - 0.0) > 1.0e-10){
189 std::cout <<
"Incorrect value for field 1, dof " << dof <<
": " << (*solution_fields.at(1))[dof] <<
" Expected value is 0" << std::endl;
195 sprintf (buffer,
"Test result for 'OrderParameterRemapper': %u\n", pass);
void remap(std::vector< SimplifiedGrainRepresentation< dim >> &grain_representations, std::vector< vectorType *> &solution_fields, dealii::DoFHandler< dim > &dof_handler, unsigned int dofs_per_cell, double buffer)
void calcGrainSets(dealii::FESystem< dim > &fe, dealii::DoFHandler< dim > &dof_handler, vectorType *solution_field, double threshold_lower, double threshold_upper, unsigned int order_parameter_index, std::vector< GrainSet< dim >> &grain_sets)
bool test_OrderParameterRemapper()
double value(const dealii::Point< dim > &p, const unsigned int component=0) const
void reassignGrains(std::vector< SimplifiedGrainRepresentation< dim >> &grain_representations, double buffer_distance, std::vector< unsigned int > order_parameter_id_list)
dealii::parallel::distributed::Vector< double > vectorType
InitialConditionOrderParameterRemapper(unsigned int _index)