Skip to content

Commit

Permalink
fixed some postprocess issues
Browse files Browse the repository at this point in the history
  • Loading branch information
fractalsbyx committed Nov 14, 2024
1 parent 9fcb873 commit ca4b4b1
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 29 deletions.
4 changes: 0 additions & 4 deletions include/userInputParameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -275,12 +275,8 @@ class userInputParameters
unsigned int pp_number_of_variables;
unsigned int num_integrated_fields;
bool postProcessingRequired;
std::vector<bool> pp_calc_integral;
std::vector<unsigned int> integrated_field_indices;

std::vector<std::string> pp_var_name;
std::vector<fieldType> pp_var_type;

// Variable and residual info
std::vector<variable_info> pp_varInfoList;
std::vector<variable_info> pp_baseVarInfoList;
Expand Down
1 change: 0 additions & 1 deletion include/variableAttributeLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ struct variableAttributes
bool need_hessian_PP = false;
bool need_value_nucleation = false;
bool nucleating_variable = false;
std::string name_pp = "";
fieldType var_type_PP = UNDEFINED_FIELD;
bool output_integral = false;
bool need_value_residual_PP = false;
Expand Down
31 changes: 12 additions & 19 deletions src/matrixfree/outputResults.cc
Original file line number Diff line number Diff line change
Expand Up @@ -84,24 +84,20 @@ MatrixFreePDE<dim, degree>::outputResults()
output_file << currentTime;
}

for (unsigned int i = 0; i < userInputs.pp_number_of_variables; i++)
for (const auto &[pp_index, pp_variable] : var_attributes.pp_attributes)
{
if (userInputs.pp_calc_integral[i])
if (pp_variable.calc_integral)
{
double integrated_field;
computeIntegral(integrated_field, i, postProcessedSet);
pcout << "Integrated value of "
<< userInputs.pp_var_name[userInputs.integrated_field_indices[i]]
<< ": " << integrated_field << std::endl;
computeIntegral(integrated_field, pp_index, postProcessedSet);
pcout << "Integrated value of " << pp_variable.name << ": "
<< integrated_field << std::endl;
if (Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) == 0)
{
output_file
<< "\t"
<< userInputs.pp_var_name[userInputs.integrated_field_indices[i]]
<< "\t" << integrated_field;
output_file << "\t" << pp_variable.name << "\t" << integrated_field;
}
integrated_postprocessed_fields.at(
userInputs.integrated_field_indices[i]) = integrated_field;
userInputs.integrated_field_indices[pp_index]) = integrated_field;
}
}
if (Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) == 0)
Expand All @@ -113,8 +109,7 @@ MatrixFreePDE<dim, degree>::outputResults()
}

// Add the postprocessed fields to data_out
for (unsigned int fieldIndex = 0; fieldIndex < userInputs.pp_number_of_variables;
fieldIndex++)
for (const auto &[fieldIndex, pp_variable] : var_attributes.pp_attributes)
{
// mark field as scalar/vector
unsigned int components;
Expand All @@ -123,9 +118,8 @@ MatrixFreePDE<dim, degree>::outputResults()
components = 1;
std::vector<DataComponentInterpretation::DataComponentInterpretation>
dataType(components, DataComponentInterpretation::component_is_scalar);
std::vector<std::string> solutionNames(
components,
userInputs.pp_var_name[fieldIndex].c_str());
std::vector<std::string> solutionNames(components,
pp_variable.name.c_str());
// add field to data_out
data_out.add_data_vector(*dofHandlersSet[0],
*postProcessedSet[fieldIndex],
Expand All @@ -138,9 +132,8 @@ MatrixFreePDE<dim, degree>::outputResults()
std::vector<DataComponentInterpretation::DataComponentInterpretation>
dataType(components,
DataComponentInterpretation::component_is_part_of_vector);
std::vector<std::string> solutionNames(
components,
userInputs.pp_var_name[fieldIndex].c_str());
std::vector<std::string> solutionNames(components,
pp_variable.name.c_str());
// add field to data_out
data_out.add_data_vector(*dofHandlersSet[0],
*postProcessedSet[fieldIndex],
Expand Down
2 changes: 1 addition & 1 deletion src/userInputParameters/loadVariableAttributes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ userInputParameters<dim>::loadVariableAttributes(
num_integrated_fields = 0;
for (const auto &[pp_index, pp_variable] : variable_attributes.pp_attributes)
{
if (pp_calc_integral[pp_index])
if (pp_variable.calc_integral)
{
num_integrated_fields++;
integrated_field_indices.push_back(pp_index);
Expand Down
8 changes: 4 additions & 4 deletions src/variableAttributeLoader/variableAttributeLoader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ variableAttributeLoader::set_variable_name(const unsigned int &index,
}
else
{
attributes[index].name_pp = name;
pp_attributes[index].name = name;
}
}

Expand All @@ -179,7 +179,7 @@ variableAttributeLoader::set_variable_type(const unsigned int &index,
}
else
{
attributes[index].var_type_PP = var_type;
pp_attributes[index].var_type_PP = var_type;
}
}

Expand Down Expand Up @@ -223,7 +223,7 @@ variableAttributeLoader::set_dependencies_value_term_RHS(const unsigned int &ind
}
else
{
attributes[index].dependencies_value_PP =
pp_attributes[index].dependencies_value_PP =
std::set<std::string>(dependencies_set.begin(), dependencies_set.end());
}
}
Expand All @@ -242,7 +242,7 @@ variableAttributeLoader::set_dependencies_gradient_term_RHS(
}
else
{
attributes[index].dependencies_gradient_PP =
pp_attributes[index].dependencies_gradient_PP =
std::set<std::string>(dependencies_set.begin(), dependencies_set.end());
}
}
Expand Down

0 comments on commit ca4b4b1

Please sign in to comment.