Skip to content

Commit

Permalink
Rename GrainSet class to Grain
Browse files Browse the repository at this point in the history
  • Loading branch information
zachcroft authored and landinjm committed Jan 27, 2025
1 parent 15181c3 commit 2f6e3bf
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 31 deletions.
12 changes: 6 additions & 6 deletions include/grains/FloodFiller.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* vertices in that grain.
*/
template <int dim>
class GrainSet
class Grain
{
public:
/**
Expand Down Expand Up @@ -111,7 +111,7 @@ class FloodFiller

/**
* The primary external interface. This method takes in information about the
* mesh/field and outputs a vector of GrainSet objects.
* mesh/field and outputs a vector of Grain objects.
*/
void
calcGrainSets(dealii::FESystem<dim> &finite_element,
Expand All @@ -121,7 +121,7 @@ class FloodFiller
double threshold_upper,
int min_id,
unsigned int order_parameter_index,
std::vector<GrainSet<dim>> &grain_sets);
std::vector<Grain<dim>> &grain_sets);

protected:
/**
Expand All @@ -136,21 +136,21 @@ class FloodFiller
double threshold_upper,
int min_id,
unsigned int &grain_index,
std::vector<GrainSet<dim>> &grain_sets,
std::vector<Grain<dim>> &grain_sets,
bool &grain_assigned);

/**
* The method to merge the grain sets from all the processors.
*/
void
createGlobalGrainSetList(std::vector<GrainSet<dim>> &grain_sets) const;
createGlobalGrainSetList(std::vector<Grain<dim>> &grain_sets) const;

/**
* Checks to see if grains found on different processors are parts of a larger
* grain. If so, it merges the grain_sets entries.
*/
void
mergeSplitGrains(std::vector<GrainSet<dim>> &grain_sets) const;
mergeSplitGrains(std::vector<Grain<dim>> &grain_sets) const;

/**
* The quadrature used to calculate the element-wise value of the solution
Expand Down
4 changes: 2 additions & 2 deletions include/grains/SimplifiedGrainRepresentation.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ class SimplifiedGrainRepresentation
public:
/**
* Constructor. Creates the simplified representation of a grain from its
* GrainSet. This sets all of the internal data members and is the only way
* Grain. This sets all of the internal data members and is the only way
* to set the radius and center of the grain. The members order_parameter_id
* and old_order_parameter_id are initialized to the same value.
*/
SimplifiedGrainRepresentation(const GrainSet<dim> &grain_set);
SimplifiedGrainRepresentation(const Grain<dim> &grain);

/**
* Getter for the grain center/centroid.
Expand Down
4 changes: 2 additions & 2 deletions src/core/initial_conditions/initialConditions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,12 @@ MatrixFreePDE<dim, degree>::applyInitialConditions()
FloodFiller<dim, degree> flood_filler(*FESet.at(scalar_field_index), quadrature2);

pcout << "Locating the grains...\n";
std::vector<GrainSet<dim>> grain_sets;
std::vector<Grain<dim>> grain_sets;
for (unsigned int id = min_id; id < max_id + 1; id++)
{
pcout << "Locating grain " << id << "...\n";

std::vector<GrainSet<dim>> grain_sets_single_id;
std::vector<Grain<dim>> grain_sets_single_id;

flood_filler.calcGrainSets(*FESet.at(scalar_field_index),
*dofHandlersSet_nonconst.at(scalar_field_index),
Expand Down
28 changes: 14 additions & 14 deletions src/grains/FloodFiller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ FloodFiller<dim, degree>::calcGrainSets(
double threshold_upper,
int min_id,
unsigned int order_parameter_index,
std::vector<GrainSet<dim>> &grain_sets)
std::vector<Grain<dim>> &grain_sets)
{
unsigned int grain_index = 0;

Expand All @@ -23,8 +23,8 @@ FloodFiller<dim, degree>::calcGrainSets(
++cell;
}

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

// The flood fill loop
Expand All @@ -49,9 +49,9 @@ FloodFiller<dim, degree>::calcGrainSets(
{
// Get the grain set initialized for the next grain to be found
grain_index++;
GrainSet<dim> new_grain_set;
new_grain_set.setOrderParameterIndex(order_parameter_index);
grain_sets.push_back(new_grain_set);
Grain<dim> new_grain;
new_grain.setOrderParameterIndex(order_parameter_index);
grain_sets.push_back(new_grain);
}
}

Expand Down Expand Up @@ -86,7 +86,7 @@ FloodFiller<dim, degree>::recursiveFloodFill(
double threshold_upper,
int min_id,
unsigned int &grain_index,
std::vector<GrainSet<dim>> &grain_sets,
std::vector<Grain<dim>> &grain_sets,
bool &grain_assigned)
{
if (cell == cell_end)
Expand Down Expand Up @@ -189,7 +189,7 @@ FloodFiller<dim, degree>::recursiveFloodFill(
template <int dim, int degree>
void
FloodFiller<dim, degree>::createGlobalGrainSetList(
std::vector<GrainSet<dim>> &grain_sets) const
std::vector<Grain<dim>> &grain_sets) const
{
unsigned int numProcs = dealii::Utilities::MPI::n_mpi_processes(MPI_COMM_WORLD);

Expand Down Expand Up @@ -308,12 +308,12 @@ FloodFiller<dim, degree>::createGlobalGrainSetList(
MPI_DOUBLE,
MPI_COMM_WORLD);

// Put the GrainSet objects back together
// Put the Grain objects back together
grain_sets.clear();

for (int g = 0; g < num_grains_global; g++)
{
GrainSet<dim> new_grain_set;
Grain<dim> new_grain;
for (unsigned int c = 0; c < num_elements_global.at(g); c++)
{
std::vector<dealii::Point<dim>> verts;
Expand All @@ -329,10 +329,10 @@ FloodFiller<dim, degree>::createGlobalGrainSetList(
dealii::Point<dim> vert(tensor_coords);
verts.push_back(vert);
}
new_grain_set.addVertexList(verts);
new_grain.addVertexList(verts);
}
new_grain_set.setOrderParameterIndex(order_parameters_global.at(g));
grain_sets.push_back(new_grain_set);
new_grain.setOrderParameterIndex(order_parameters_global.at(g));
grain_sets.push_back(new_grain);
}
}

Expand All @@ -342,7 +342,7 @@ FloodFiller<dim, degree>::createGlobalGrainSetList(

template <int dim, int degree>
void
FloodFiller<dim, degree>::mergeSplitGrains(std::vector<GrainSet<dim>> &grain_sets) const
FloodFiller<dim, degree>::mergeSplitGrains(std::vector<Grain<dim>> &grain_sets) const
{
// Loop though each vertex in the base grain "g"
for (unsigned int g = 0; g < grain_sets.size(); g++)
Expand Down
9 changes: 4 additions & 5 deletions src/grains/SimplifiedGrainRepresentation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,15 @@
// ============================================================================

template <int dim>
SimplifiedGrainRepresentation<dim>::SimplifiedGrainRepresentation(
const GrainSet<dim> &grain_set)
: grain_id(grain_set.getGrainIndex())
, order_parameter_id(grain_set.getOrderParameterIndex())
SimplifiedGrainRepresentation<dim>::SimplifiedGrainRepresentation(const Grain<dim> &grain)
: grain_id(grain.getGrainIndex())
, order_parameter_id(grain.getOrderParameterIndex())
, old_order_parameter_id(order_parameter_id)
, distance_to_neighbor_sharing_op(0.0)
{
// Calculate the centroid assuming that the elements are rectangular and with
// no weighting based on the actual value of the field
std::vector<std::vector<dealii::Point<dim>>> vertex_list = grain_set.getVertexList();
std::vector<std::vector<dealii::Point<dim>>> vertex_list = grain.getVertexList();

double grain_volume = 0.0;
dealii::Tensor<1, dim> centroid;
Expand Down
4 changes: 2 additions & 2 deletions src/grains/reassignGrains.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ MatrixFreePDE<dim, degree>::reassignGrains()
QGaussLobatto<dim> quadrature2(degree + 1);
FloodFiller<dim, degree> flood_filler(*FESet.at(scalar_field_index), quadrature2);

std::vector<GrainSet<dim>> grain_sets;
std::vector<Grain<dim>> grain_sets;

unsigned int op_list_index = 0;
for (unsigned int fieldIndex = 0; fieldIndex < fields.size(); fieldIndex++)
Expand All @@ -40,7 +40,7 @@ MatrixFreePDE<dim, degree>::reassignGrains()
{
op_list_index++;

std::vector<GrainSet<dim>> single_OP_grain_sets;
std::vector<Grain<dim>> single_OP_grain_sets;
flood_filler.calcGrainSets(*FESet.at(scalar_field_index),
*dofHandlersSet_nonconst.at(scalar_field_index),
solutionSet.at(fieldIndex),
Expand Down

0 comments on commit 2f6e3bf

Please sign in to comment.