Skip to content

Commit

Permalink
fixing some sort variable names
Browse files Browse the repository at this point in the history
  • Loading branch information
landinjm committed Oct 24, 2024
1 parent 192dd36 commit 66ac723
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 66 deletions.
10 changes: 4 additions & 6 deletions include/FloodFiller.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,16 +111,14 @@ class FloodFiller
: quadrature(_quadrature)
, num_quad_points(_quadrature.size())
, dofs_per_cell(_fe.dofs_per_cell)
{
fe = &_fe;
};
, fe(&_fe) {};

/**
* The primary external interface. This method takes in information about the
* mesh/field and outputs a vector of GrainSet objects.
*/
void
calcGrainSets(dealii::FESystem<dim> &fe,
calcGrainSets(dealii::FESystem<dim> &finite_element,
dealii::DoFHandler<dim> &dof_handler,
vectorType *solution_field,
double threshold_lower,
Expand All @@ -135,8 +133,8 @@ class FloodFiller
*/
template <typename T>
void
recursiveFloodFill(T di,
T di_end,
recursiveFloodFill(T cell,
T cell_end,
vectorType *solution_field,
double threshold_lower,
double threshold_upper,
Expand Down
24 changes: 12 additions & 12 deletions include/RefinementCriterion.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,34 @@ enum RefinementCriterionFlags

// Function that enables bitwise OR between flags
inline RefinementCriterionFlags
operator|(const RefinementCriterionFlags f1, const RefinementCriterionFlags f2)
operator|(const RefinementCriterionFlags flag_1, const RefinementCriterionFlags flag_2)
{
return static_cast<RefinementCriterionFlags>(static_cast<unsigned int>(f1) |
static_cast<unsigned int>(f2));
return static_cast<RefinementCriterionFlags>(static_cast<unsigned int>(flag_1) |
static_cast<unsigned int>(flag_2));
}

// Function that enables bitwise compound OR between flags
inline RefinementCriterionFlags &
operator|=(RefinementCriterionFlags &f1, const RefinementCriterionFlags f2)
operator|=(RefinementCriterionFlags &flag_1, const RefinementCriterionFlags flag_2)
{
f1 = f1 | f2;
return f1;
flag_1 = flag_1 | flag_2;
return flag_1;
}

// Function that enables bitwise AND between flags
inline RefinementCriterionFlags
operator&(const RefinementCriterionFlags f1, const RefinementCriterionFlags f2)
operator&(const RefinementCriterionFlags flag_1, const RefinementCriterionFlags flag_2)
{
return static_cast<RefinementCriterionFlags>(static_cast<unsigned int>(f1) &
static_cast<unsigned int>(f2));
return static_cast<RefinementCriterionFlags>(static_cast<unsigned int>(flag_1) &
static_cast<unsigned int>(flag_2));
}

// Function that enables bitwise compound AND between flags
inline RefinementCriterionFlags &
operator&=(RefinementCriterionFlags &f1, const RefinementCriterionFlags f2)
operator&=(RefinementCriterionFlags &flag_1, const RefinementCriterionFlags flag_2)
{
f1 = f1 & f2;
return f1;
flag_1 = flag_1 & flag_2;
return flag_1;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions include/SimplifiedGrainRepresentation.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class SimplifiedGrainRepresentation
* Setter for the grain id.
*/
void
setGrainId(unsigned int id);
setGrainId(unsigned int _grain_id);

/**
* Getter for the order parameter id.
Expand All @@ -56,7 +56,7 @@ class SimplifiedGrainRepresentation
* Setter for the order parameter id.
*/
void
setOrderParameterId(unsigned int id);
setOrderParameterId(unsigned int _order_parameter_id);

/**
* Getter for the old value of the order parameter id (used in the
Expand Down
59 changes: 30 additions & 29 deletions src/FloodFiller/FloodFiller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

template <int dim, int degree>
void
FloodFiller<dim, degree>::calcGrainSets(dealii::FESystem<dim> &fe,
FloodFiller<dim, degree>::calcGrainSets(dealii::FESystem<dim> &finite_element,
dealii::DoFHandler<dim> &dof_handler,
vectorType *solution_field,
double threshold_lower,
Expand All @@ -17,26 +17,26 @@ FloodFiller<dim, degree>::calcGrainSets(dealii::FESystem<dim> &fe,

// Loop through the whole mesh and set the user flags to false (so everything
// is considered unmarked)
typename dealii::DoFHandler<dim>::cell_iterator di = dof_handler.begin();
while (di != dof_handler.end())
typename dealii::DoFHandler<dim>::cell_iterator cell = dof_handler.begin();
while (cell != dof_handler.end())
{
di->clear_user_flag();
++di;
cell->clear_user_flag();
++cell;
}

GrainSet<dim> grain_set;
grain_sets.push_back(grain_set);
grain_sets.back().setOrderParameterIndex(order_parameter_index);

// The flood fill loop
di = dof_handler.begin();
while (di != dof_handler.end())
cell = dof_handler.begin();
while (cell != dof_handler.end())
{
if (!di->has_children())
if (!cell->has_children())
{
bool grain_assigned = false;
recursiveFloodFill<typename dealii::DoFHandler<dim>::cell_iterator>(
di,
cell,
dof_handler.end(),
solution_field,
threshold_lower,
Expand All @@ -56,7 +56,7 @@ FloodFiller<dim, degree>::calcGrainSets(dealii::FESystem<dim> &fe,
}
}

++di;
++cell;
}

// If the last grain was initialized but empty, delete it
Expand All @@ -79,8 +79,8 @@ FloodFiller<dim, degree>::calcGrainSets(dealii::FESystem<dim> &fe,
template <int dim, int degree>
template <typename T>
void
FloodFiller<dim, degree>::recursiveFloodFill(T di,
T di_end,
FloodFiller<dim, degree>::recursiveFloodFill(T cell,
T cell_end,
vectorType *solution_field,
double threshold_lower,
double threshold_upper,
Expand All @@ -89,20 +89,20 @@ FloodFiller<dim, degree>::recursiveFloodFill(T di,
std::vector<GrainSet<dim>> &grain_sets,
bool &grain_assigned)
{
if (di != di_end)
if (cell != cell_end)
{
// Check if the cell has been marked yet
bool cellMarked = di->user_flag_set();
bool cellMarked = cell->user_flag_set();

if (!cellMarked)
{
if (di->has_children())
if (cell->has_children())
{
// Call recursiveFloodFill on the element's children
for (unsigned int n = 0; n < di->n_children(); n++)
for (unsigned int n_child = 0; n_child < cell->n_children(); n_child++)
{
recursiveFloodFill<T>(di->child(n),
di_end,
recursiveFloodFill<T>(cell->child(n_child),
cell_end,
solution_field,
threshold_lower,
threshold_upper,
Expand All @@ -114,16 +114,17 @@ FloodFiller<dim, degree>::recursiveFloodFill(T di,
}
else
{
if (di->is_locally_owned())
if (cell->is_locally_owned())
{
di->set_user_flag();
cell->set_user_flag();

dealii::FEValues<dim> fe_values(*fe, quadrature, dealii::update_values);
std::vector<double> var_values(num_quad_points);

std::vector<double> var_values(num_quad_points);
std::vector<dealii::Point<dim>> q_point_list(num_quad_points);

// Get the most common value for the element
fe_values.reinit(di);
fe_values.reinit(cell);
fe_values.get_function_values(*solution_field, var_values);

double ele_val;
Expand Down Expand Up @@ -151,19 +152,19 @@ FloodFiller<dim, degree>::recursiveFloodFill(T di,
grain_assigned = true;

std::vector<dealii::Point<dim>> vertex_list;
for (unsigned int v = 0;
v < dealii::Utilities::fixed_power<dim>(2.0);
v++)
for (unsigned int vertex_index = 0;
vertex_index < dealii::Utilities::fixed_power<dim>(2.0);
vertex_index++)
{
vertex_list.push_back(di->vertex(v));
vertex_list.push_back(cell->vertex(vertex_index));
}
grain_sets.back().addVertexList(vertex_list);

// Call recursiveFloodFill on the element's neighbors
for (unsigned int n = 0; n < 2 * dim; n++)
for (unsigned int n_child = 0; n_child < 2 * dim; n_child++)
{
recursiveFloodFill<T>(di->neighbor(n),
di_end,
recursiveFloodFill<T>(cell->neighbor(n_child),
cell_end,
solution_field,
threshold_lower,
threshold_upper,
Expand Down
36 changes: 19 additions & 17 deletions src/SimplifiedGrainRepresentation/SimplifiedGrainRepresentation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ SimplifiedGrainRepresentation<dim>::SimplifiedGrainRepresentation(
double grain_volume = 0.0;
dealii::Tensor<1, dim> centroid;

for (unsigned int c = 0; c < vertex_list.size(); c++)
for (auto &vertex : vertex_list)
{
double cell_volume = 1.0;
dealii::Point<dim> cell_center;
Expand All @@ -35,39 +35,41 @@ SimplifiedGrainRepresentation<dim>::SimplifiedGrainRepresentation(
opposite_corner_index = 7;
}

for (unsigned int d = 0; d < dim; d++)
for (unsigned int dimension = 0; dimension < dim; dimension++)
{
cell_volume *=
(vertex_list.at(c)[opposite_corner_index][d] - vertex_list.at(c)[0][d]);
cell_center(d) =
(vertex_list.at(c)[opposite_corner_index][d] + vertex_list.at(c)[0][d]) / 2.0;
(vertex[opposite_corner_index][dimension] - vertex[0][dimension]);
cell_center(dimension) =
(vertex[opposite_corner_index][dimension] + vertex[0][dimension]) / 2.0;
}

for (unsigned int d = 0; d < dim; d++)
for (unsigned int dimension = 0; dimension < dim; dimension++)
{
centroid[d] += cell_volume * cell_center(d);
centroid[dimension] += cell_volume * cell_center(dimension);
}

grain_volume += cell_volume;
}

centroid /= grain_volume;

for (unsigned int d = 0; d < dim; d++)
for (unsigned int dimension = 0; dimension < dim; dimension++)
{
center(d) = centroid[d];
center(dimension) = centroid[dimension];
}

// Calculate the radius as the largest distance from the centroid to one of
// the vertices
radius = 0.0;
for (unsigned int c = 0; c < vertex_list.size(); c++)
for (auto &vertex : vertex_list)
{
for (unsigned int v = 0; v < dealii::Utilities::fixed_power<dim>(2.0); v++)
for (unsigned int vertex_index = 0;
vertex_index < dealii::Utilities::fixed_power<dim>(2.0);
vertex_index++)
{
if (vertex_list[c][v].distance(center) > radius)
if (vertex[vertex_index].distance(center) > radius)
{
radius = vertex_list[c][v].distance(center);
radius = vertex[vertex_index].distance(center);
}
}
}
Expand Down Expand Up @@ -96,9 +98,9 @@ SimplifiedGrainRepresentation<dim>::getGrainId() const

template <int dim>
void
SimplifiedGrainRepresentation<dim>::setGrainId(unsigned int id)
SimplifiedGrainRepresentation<dim>::setGrainId(unsigned int _grain_id)
{
grain_id = id;
grain_id = _grain_id;
}

template <int dim>
Expand All @@ -110,9 +112,9 @@ SimplifiedGrainRepresentation<dim>::getOrderParameterId() const

template <int dim>
void
SimplifiedGrainRepresentation<dim>::setOrderParameterId(unsigned int id)
SimplifiedGrainRepresentation<dim>::setOrderParameterId(unsigned int _order_parameter_id)
{
order_parameter_id = id;
order_parameter_id = _order_parameter_id;
}

template <int dim>
Expand Down

0 comments on commit 66ac723

Please sign in to comment.