Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Seperate attributes #348

Merged
merged 4 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions applications/allenCahn_conserved/customPDE.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ customPDE<dim, degree>::solveIncrement(bool skip_time_dependent)
this->fields[fieldIndex].pdetype == TIME_INDEPENDENT)
{
if (this->currentIncrement % userInputs.skip_print_steps == 0 &&
this->var_attributes.attributes.at(fieldIndex).is_nonlinear)
this->var_attributes.at(fieldIndex).is_nonlinear)
{
snprintf(buffer,
sizeof(buffer),
Expand All @@ -222,12 +222,12 @@ customPDE<dim, degree>::solveIncrement(bool skip_time_dependent)
}
else if (this->fields[fieldIndex].pdetype == AUXILIARY)
{
if (this->var_attributes.attributes.at(fieldIndex).is_nonlinear ||
if (this->var_attributes.at(fieldIndex).is_nonlinear ||
nonlinear_it_index == 0)
{
// If the equation for this field is nonlinear, save the
// old solution
if (this->var_attributes.attributes.at(fieldIndex).is_nonlinear)
if (this->var_attributes.at(fieldIndex).is_nonlinear)
{
if (this->fields[fieldIndex].type == SCALAR)
{
Expand Down Expand Up @@ -258,7 +258,7 @@ customPDE<dim, degree>::solveIncrement(bool skip_time_dependent)
}

// Check to see if this individual variable has converged
if (this->var_attributes.attributes.at(fieldIndex).is_nonlinear)
if (this->var_attributes.at(fieldIndex).is_nonlinear)
{
if (MatrixFreePDE<dim, degree>::userInputs
.nonlinear_solver_parameters.getToleranceType(
Expand Down
10 changes: 5 additions & 5 deletions applications/grainGrowth/equations.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,16 @@ customPDE<dim, degree>::explicitEquationRHS(
// to set the residual terms until all the residuals have been calculated.

std::vector<scalarvalueType> value_terms;
value_terms.resize(userInputs.number_of_variables);
value_terms.resize(userInputs.var_attributes.size());
std::vector<scalargradType> gradient_terms;
gradient_terms.resize(userInputs.number_of_variables);
gradient_terms.resize(userInputs.var_attributes.size());

for (unsigned int i = 0; i < userInputs.number_of_variables; i++)
for (unsigned int i = 0; i < userInputs.var_attributes.size(); i++)
{
ni = variable_list.get_scalar_value(i);
nix = variable_list.get_scalar_gradient(i);
fnV = -ni + ni * ni * ni;
for (unsigned int j = 0; j < userInputs.number_of_variables; j++)
for (unsigned int j = 0; j < userInputs.var_attributes.size(); j++)
{
if (i != j)
{
Expand All @@ -89,7 +89,7 @@ customPDE<dim, degree>::explicitEquationRHS(

// --- Submitting the terms for the governing equations ---

for (unsigned int i = 0; i < userInputs.number_of_variables; i++)
for (unsigned int i = 0; i < userInputs.var_attributes.size(); i++)
{
variable_list.set_scalar_value_term_RHS(i, value_terms[i]);
variable_list.set_scalar_gradient_term_RHS(i, gradient_terms[i]);
Expand Down
4 changes: 2 additions & 2 deletions applications/grainGrowth/postprocess.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ customPDE<dim, degree>::postProcessedFields(

scalarvalueType max_val = constV(-1.0);
scalarvalueType max_op = constV(100.0);
for (unsigned int i = 0; i < userInputs.number_of_variables; i++)
for (unsigned int i = 0; i < userInputs.var_attributes.size(); i++)
{
ni = variable_list.get_scalar_value(i);

Expand Down Expand Up @@ -109,7 +109,7 @@ customPDE<dim, degree>::postProcessedFields(
}

scalarvalueType sum_n = constV(0.0);
for (unsigned int i = 0; i < userInputs.number_of_variables; i++)
for (unsigned int i = 0; i < userInputs.var_attributes.size(); i++)
{
ni = variable_list.get_scalar_value(i);
sum_n += ni;
Expand Down
10 changes: 5 additions & 5 deletions applications/grainGrowth_dream3d/equations.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,16 @@ customPDE<dim, degree>::explicitEquationRHS(
// to set the residual terms until all the residuals have been calculated.

std::vector<scalarvalueType> value_terms;
value_terms.resize(userInputs.number_of_variables);
value_terms.resize(userInputs.var_attributes.size());
std::vector<scalargradType> gradient_terms;
gradient_terms.resize(userInputs.number_of_variables);
gradient_terms.resize(userInputs.var_attributes.size());

for (unsigned int i = 0; i < userInputs.number_of_variables; i++)
for (unsigned int i = 0; i < userInputs.var_attributes.size(); i++)
{
ni = variable_list.get_scalar_value(i);
nix = variable_list.get_scalar_gradient(i);
fnV = -ni + ni * ni * ni;
for (unsigned int j = 0; j < userInputs.number_of_variables; j++)
for (unsigned int j = 0; j < userInputs.var_attributes.size(); j++)
{
if (i != j)
{
Expand All @@ -100,7 +100,7 @@ customPDE<dim, degree>::explicitEquationRHS(

// --- Submitting the terms for the governing equations ---

for (unsigned int i = 0; i < userInputs.number_of_variables; i++)
for (unsigned int i = 0; i < userInputs.var_attributes.size(); i++)
{
variable_list.set_scalar_value_term_RHS(i, value_terms[i]);
variable_list.set_scalar_gradient_term_RHS(i, gradient_terms[i]);
Expand Down
4 changes: 2 additions & 2 deletions applications/grainGrowth_dream3d/postprocess.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ customPDE<dim, degree>::postProcessedFields(

scalarvalueType max_val = constV(-100.0);
scalarvalueType max_op = constV(100.0);
for (unsigned int i = 0; i < userInputs.number_of_variables; i++)
for (unsigned int i = 0; i < userInputs.var_attributes.size(); i++)
{
ni = variable_list.get_scalar_value(i);

Expand Down Expand Up @@ -121,7 +121,7 @@ customPDE<dim, degree>::postProcessedFields(
}

scalarvalueType sum_n = constV(0.0);
for (unsigned int i = 0; i < userInputs.number_of_variables; i++)
for (unsigned int i = 0; i < userInputs.var_attributes.size(); i++)
{
ni = variable_list.get_scalar_value(i);
sum_n += ni;
Expand Down
14 changes: 8 additions & 6 deletions applications/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,12 @@ main(int argc, char **argv)
// postprocessing variables there are, how many sets of elastic constants
// there are, and how many user-defined constants there are.

variableAttributeLoader variable_attributes;
inputFileReader input_file_reader(parameters_filename, variable_attributes);
const variableAttributeLoader attribute_loader;
const AttributesList var_attributes = attribute_loader.get_var_attributes();
const AttributesList pp_attributes = attribute_loader.get_pp_attributes();
inputFileReader input_file_reader(parameters_filename,
var_attributes,
pp_attributes);

// Continue based on the number of dimensions and degree of the elements
// specified in the input file
Expand All @@ -72,8 +76,7 @@ main(int argc, char **argv)
case 2:
{
userInputParameters<2> userInputs(input_file_reader,
input_file_reader.parameter_handler,
variable_attributes);
input_file_reader.parameter_handler);
switch (userInputs.degree)
{
case (1):
Expand Down Expand Up @@ -130,8 +133,7 @@ main(int argc, char **argv)
case 3:
{
userInputParameters<3> userInputs(input_file_reader,
input_file_reader.parameter_handler,
variable_attributes);
input_file_reader.parameter_handler);
switch (userInputs.degree)
{
case (1):
Expand Down
10 changes: 5 additions & 5 deletions automatic_tests/grainGrowth/equations.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,16 @@ customPDE<dim, degree>::explicitEquationRHS(
// to set the residual terms until all the residuals have been calculated.

std::vector<scalarvalueType> value_terms;
value_terms.resize(userInputs.number_of_variables);
value_terms.resize(userInputs.var_attributes.size());
std::vector<scalargradType> gradient_terms;
gradient_terms.resize(userInputs.number_of_variables);
gradient_terms.resize(userInputs.var_attributes.size());

for (unsigned int i = 0; i < userInputs.number_of_variables; i++)
for (unsigned int i = 0; i < userInputs.var_attributes.size(); i++)
{
ni = variable_list.get_scalar_value(i);
nix = variable_list.get_scalar_gradient(i);
fnV = -ni + ni * ni * ni;
for (unsigned int j = 0; j < userInputs.number_of_variables; j++)
for (unsigned int j = 0; j < userInputs.var_attributes.size(); j++)
{
if (i != j)
{
Expand All @@ -89,7 +89,7 @@ customPDE<dim, degree>::explicitEquationRHS(

// --- Submitting the terms for the governing equations ---

for (unsigned int i = 0; i < userInputs.number_of_variables; i++)
for (unsigned int i = 0; i < userInputs.var_attributes.size(); i++)
{
variable_list.set_scalar_value_term_RHS(i, value_terms[i]);
variable_list.set_scalar_gradient_term_RHS(i, gradient_terms[i]);
Expand Down
4 changes: 2 additions & 2 deletions automatic_tests/grainGrowth/postprocess.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ customPDE<dim, degree>::postProcessedFields(

scalarvalueType max_val = constV(-1.0);
scalarvalueType max_op = constV(100.0);
for (unsigned int i = 0; i < userInputs.number_of_variables; i++)
for (unsigned int i = 0; i < userInputs.var_attributes.size(); i++)
{
ni = variable_list.get_scalar_value(i);

Expand Down Expand Up @@ -109,7 +109,7 @@ customPDE<dim, degree>::postProcessedFields(
}

scalarvalueType sum_n = constV(0.0);
for (unsigned int i = 0; i < userInputs.number_of_variables; i++)
for (unsigned int i = 0; i < userInputs.var_attributes.size(); i++)
{
ni = variable_list.get_scalar_value(i);
sum_n += ni;
Expand Down
15 changes: 9 additions & 6 deletions automatic_tests/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <core/ParseCommandLineOpts.h>
#include <core/inputFileReader.h>
#include <core/variableAttributeLoader.h>
#include <core/variableAttributes.h>

// Header file for postprocessing that may or may not exist
#ifdef POSTPROCESS_FILE_EXISTS
Expand Down Expand Up @@ -62,8 +63,12 @@ main(int argc, char **argv)
// postprocessing variables there are, how many sets of elastic constants
// there are, and how many user-defined constants there are.

variableAttributeLoader variable_attributes;
inputFileReader input_file_reader(parameters_filename, variable_attributes);
const variableAttributeLoader attribute_loader;
const AttributesList var_attributes = attribute_loader.get_var_attributes();
const AttributesList pp_attributes = attribute_loader.get_pp_attributes();
inputFileReader input_file_reader(parameters_filename,
var_attributes,
pp_attributes);

// Continue based on the number of dimensions and degree of the elements
// specified in the input file
Expand All @@ -72,8 +77,7 @@ main(int argc, char **argv)
case 2:
{
userInputParameters<2> userInputs(input_file_reader,
input_file_reader.parameter_handler,
variable_attributes);
input_file_reader.parameter_handler);
switch (userInputs.degree)
{
case (1):
Expand Down Expand Up @@ -130,8 +134,7 @@ main(int argc, char **argv)
case 3:
{
userInputParameters<3> userInputs(input_file_reader,
input_file_reader.parameter_handler,
variable_attributes);
input_file_reader.parameter_handler);
switch (userInputs.degree)
{
case (1):
Expand Down
9 changes: 5 additions & 4 deletions include/core/inputFileReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ class inputFileReader
/**
* \brief Constructor.
*/
inputFileReader(const std::string &input_file_name,
variableAttributeLoader &_variable_attributes);
inputFileReader(const std::string &input_file_name,
const AttributesList &_var_attributes,
const AttributesList &_pp_attributes);

/**
* \brief Method to get a list of entry values from multiple subsections in an input
Expand Down Expand Up @@ -77,9 +78,9 @@ class inputFileReader
static bool
check_keyword_match(std::string &line, const std::string &keyword);

variableAttributeLoader &variable_attributes;
const AttributesList &var_attributes;
const AttributesList &pp_attributes;
dealii::ParameterHandler parameter_handler;
unsigned int num_pp_vars;
unsigned int num_constants;
std::vector<std::string> model_constant_names;
unsigned int number_of_dimensions;
Expand Down
10 changes: 4 additions & 6 deletions include/core/matrixFreePDE.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,10 @@ class MatrixFreePDE : public Subscriptor

unsigned int totalDOFs;

// Virtual methods to set the attributes of the primary field variables and
// the postprocessing field variables virtual void setVariableAttriubutes() =
// 0; virtual void setPostProcessingVariableAttriubutes(){};
variableAttributeLoader var_attributes;
// The attributes of the primary field variables and
// the postprocessing field variables
const AttributesList &var_attributes;
const AttributesList &pp_attributes;

// Elasticity matrix variables
const static unsigned int CIJ_tensor_size = 2 * dim - 1 + dim / 3;
Expand Down Expand Up @@ -489,8 +489,6 @@ class MatrixFreePDE : public Subscriptor
/*Timer and logging object*/
mutable TimerOutput computing_timer;

std::vector<double> integrated_postprocessed_fields;

bool first_integrated_var_output_complete;

// Methods and variables for integration
Expand Down
Loading
Loading