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_volume_fractions 
( 
const std::vector< double > & 
compositional_fields, 


const ComponentMask & 
field_mask = ComponentMask() 

) 
 
For multicomponent material models: Given a vector of of compositional fields of length N, this function returns a vector of volume fractions of length N+1, corresponding to the volume fraction of a ``background material'' as the first entry, and volume 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 mantle (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 background mantle. 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 nonvolumetric quantities like strain, porosity, or trace elements). By default, all fields are included.
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
.