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.
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
Thanks for the help! IAfter some struggles, I tried adding this step by step; when I only copied the line:
out.additional_outputs.push_back(
std::make_unique<MaterialModel::SeismicAdditionalOutputs> (n_quadrature_points));
I had no problem compiling. But then when I change this to:
out.additional_outputs.push_back(
std_cxx14::make_unique<MaterialModel::NamedAdditionalMaterialOutputs> (n_quadrature_points));
I get the following error:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/usr/include/c++/v1/memory:2755:32: 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/aniso_stress.cc:60:34: 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?
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 grain_size.cc, PlasticAdditionalOutputs in rheology/visco_plastic.cc. Once you’ve made that, you can then create an instance of that specific class (for example, shear_heating.cc uses the DislocationViscosityOutputs):