A namespace in which we define utility functions that might be used in many different places in the material model to prevent code duplication.
std::vector<double> aspect::MaterialModel::MaterialUtilities::compute_only_composition_fractions 
( 
const std::vector< double > & 
compositional_fields, 


const std::vector< unsigned int > & 
indices_to_use 

) 
 
For multicomponent material models: Given a vector of compositional field values of length N, of which M indices correspond to mass or volume fractions, this function returns a vector of fractions of length M+1, corresponding to the fraction of a ``background material'' as the first entry, and fractions for each of the input fields as the following entries. The returned vector will sum to one. If the sum of the compositional_fields is greater than one, we assume that there is no background field (i.e., that field value is zero). Otherwise, the difference between the sum of the compositional fields and 1.0 is assumed to be the amount of the background field. This function makes no assumptions about the units of the compositional field values; for example, they could correspond to mass or volume fractions.
std::vector<double> aspect::MaterialModel::MaterialUtilities::compute_composition_fractions 
( 
const std::vector< double > & 
compositional_fields, 


const ComponentMask & 
field_mask = ComponentMask() 

) 
 
For multicomponent material models: Given a vector of compositional field values of length N, this function returns a vector of fractions of length N+1, corresponding to the fraction of a ``background material'' as the first entry, and fractions for each of the input fields as the following entries. The returned vector will sum to one. If the sum of the compositional_fields is greater than one, we assume that there is no background field (i.e., that field value is zero). Otherwise, the difference between the sum of the compositional fields and 1.0 is assumed to be the amount of the background field. Optionally, one can input a component mask that determines which of the compositional fields to use during the computation (e.g. because some fields contain unrelated quantities (like strain, porosity, or trace elements). By default, all fields are included. This function makes no assumptions about the units of the compositional field values; for example, they could correspond to mass or volume fractions.
double aspect::MaterialModel::MaterialUtilities::average_value 
( 
const std::vector< double > & 
volume_fractions, 


const std::vector< double > & 
parameter_values, 


const CompositionalAveragingOperation & 
average_type 

) 
 
For multicomponent material models: Material models compute output quantities such as the viscosity, the density, etc. For some models, these values depend strongly on the composition, and more than one compositional field might have nonzero values at a given quadrature point. This means that properties have to be averaged based on the fractions of each compositional field present. This function performs this type of averaging. The averaging is based on the choice in average_type
. Averaging is conducted over the compositional fields given in volume_fractions
. This means that volume_fractions
and parameter_values
have to have the same size, which would typically be the number of compositional fields used in the simulation (with the potential addition of a background field, in case the composition does not add up to 1). However, one might not want to average over all fields, as in some cases compositional fields do not represent a rock type, but other tracked quantities like the finite strain, so the implementation is independent of the number of entries in volume_fractions
.
double aspect::MaterialModel::MaterialUtilities::phase_average_value 
( 
const std::vector< double > & 
phase_function_values, 


const std::vector< unsigned int > & 
n_phase_transitions_per_composition, 


const std::vector< double > & 
parameter_values, 


const unsigned int 
composition_index, 


const PhaseUtilities::PhaseAveragingOperation 
operation = PhaseUtilities::arithmetic 

) 
 
Material models compute output quantities such as the viscosity, the density, etc. For some models, these values may depend on the phase in addition to the composition, and more than one phase field might have nonzero values at a given quadrature point. This means that properties for each composition have to be averaged based on the fractions of each phase field present. This function performs this type of averaging. The averaging is based on the choice in operation
. Averaging is conducted over the phase functions given in phase_function_values
, with parameter_values
containing values of all individual phases. Unlike the average_value function defined for compositions, averaging in this function is calculated based on phase functions and the change of variables on the trajectory of phase boundaries. Thus on a single phase boundary, values of variables change gradually from one phase to the other. The values of the phase function used to average the properties varies between 0 and 1.