Accessing additional named outputs in postprocessors


I am trying to create a postprocessor, similar to the shear_stress / stress postprocessors, where I would like to calculate the so-called “anisotropic stress”, for which I would need to access the additional named outputs from the material models. I couldn’t find any examples of using additional outputs in postprocessors. Does anyone have some tips on how to access it? I guess it should look something like this:
for (unsigned int i = 0; i < Tensor<4,dim>::n_independent_components ; ++i)
stress_strain_directors[Tensor<4,dim>::unrolled_to_component_indices(i)] = additional_named_outputs[q][I],
except that additional_named_outputs is not correct.


Hi Agi,

You could have a look at the seismic_anomalies postprocessor. It uses the SeismicAdditionalOutputs. (So it’s slightly different from the NamedAdditionalOutputs, but the general way of how to access the outputs should be the same). You have to make sure that

(1) The additional outputs are created for your material model outputs object before the material model is evaluated

                      std::make_unique<MaterialModel::SeismicAdditionalOutputs<dim>> (n_q_points));

(2) In a second step, you can then get a pointer to the additional output object and use it

MaterialModel::SeismicAdditionalOutputs<dim> *seismic_outputs
                      = out.template get_additional_output<MaterialModel::SeismicAdditionalOutputs<dim>>();
const double Vs = seismic_outputs->vs[0];

Hope that helps!

Hi Juliane,

Thanks for the help! IAfter some struggles, I tried adding this step by step; when I only copied the line:
std::make_unique<MaterialModel::SeismicAdditionalOutputs> (n_quadrature_points));
I had no problem compiling. But then when I change this to:
std_cxx14::make_unique<MaterialModel::NamedAdditionalMaterialOutputs> (n_quadrature_points));
I get the following error:
/Applications/ error: no matching constructor for initialization of ‘aspect::MaterialModel::NamedAdditionalMaterialOutputs<3>’
return unique_ptr<_Tp>(new _Tp(_VSTD::forward<_Args>(__args)…));
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Applications/aspect/source/postprocess/visualization/ note: in instantiation of function template specialization ‘std::__1::make_unique<aspect::MaterialModel::NamedAdditionalMaterialOutputs<3>, const unsigned int &>’ requested here
std_cxx14::make_unique<MaterialModel::NamedAdditionalMaterialOutputs> (n_quadrature_points));
/Applications/aspect/include/aspect/material_model/interface.h:837:11: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from ‘const unsigned int’ to ‘const aspect::MaterialModel::NamedAdditionalMaterialOutputs<3>’ for 1st argument
class NamedAdditionalMaterialOutputs : public AdditionalMaterialOutputs
/Applications/aspect/include/aspect/material_model/interface.h:848:9: note: candidate constructor not viable: no known conversion from ‘const unsigned int’ to ‘const std::vectorstd::string’ (aka ‘const vector<basic_string>’) for 1st argument
NamedAdditionalMaterialOutputs(const std::vectorstd::string &output_names);
/Applications/aspect/include/aspect/material_model/interface.h:860:9: note: candidate constructor not viable: requires 2 arguments, but 1 was provided
NamedAdditionalMaterialOutputs(const std::vectorstd::string &output_names,
2 errors generated.

Is this because the NamedAdditionalMaterialOutputs contain the names of the outputs?


Hi Ági,

I think what you want to do here is not create a general NamedAdditionalMaterialOutputs object, but an instance of your specific NamedAdditionalMaterialOutputs. Did you already make that? There are several examples in other material models: DislocationViscosityOutputs in, PlasticAdditionalOutputs in rheology/ Once you’ve made that, you can then create an instance of that specific class (for example, uses the DislocationViscosityOutputs):

const MaterialModel::DislocationViscosityOutputs<dim> *disl_viscosities_out =
        material_model_outputs.template get_additional_output<MaterialModel::DislocationViscosityOutputs<dim>>();


Ah, this makes a lot of sense. I actually use this within the anisotropic viscosity material model for the assemblers.
It works now! Thanks Juliane :slight_smile: