New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create a new MaterialModel constructor. #1537
Create a new MaterialModel constructor. #1537
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are also a number of places where the code indentation seems off. Running astyle should fix that.
EDIT: nevermind, my browser rendering was acting up. Indentation seems fine.
I am very excited for this.
@@ -180,6 +182,16 @@ namespace aspect | |||
MaterialModelInputs(const unsigned int n_points, | |||
const unsigned int n_comp); | |||
|
|||
|
|||
//************************************** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment block should be of the same style as the other comment blocks (especially starting with /**
). It is with this formatting that the documentation generation is able to grab your description.
source/material_model/interface.cc
Outdated
velocity(fe.n_quadrature_points, numbers::signaling_nan<Tensor<1,dim> >()), | ||
composition(fe.n_quadrature_points, std::vector<double>(introspection.n_compositional_fields, numbers::signaling_nan<double>())), | ||
strain_rate(fe.n_quadrature_points, numbers::signaling_nan<SymmetricTensor<2,dim> >()), | ||
cell (NULL) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be initialized. I think that fe.get_cell()
would work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I get an error with fe.get_cell() . Trying to troubleshoot
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I know and know how to work around, but would need to see the error first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/home/paulbremner/install/ASPECT/aspect/devel/source/material_model/interface.cc:270:7: error: class ‘aspect::MaterialModel::MaterialModelInputs’ does not have any field named ‘fe’
fe.get_cell()
^
/home/paulbremner/install/ASPECT/aspect/devel/source/material_model/interface.cc:270:9: error: expected ‘(’ before ‘.’ token
fe.get_cell()
^
/home/paulbremner/install/ASPECT/aspect/devel/source/material_model/interface.cc:270:9: error: expected ‘{’ before ‘.’ token
/home/paulbremner/install/ASPECT/aspect/devel/source/material_model/interface.cc: At global scope:
/home/paulbremner/install/ASPECT/aspect/devel/source/material_model/interface.cc:270:9: error: expected unqualified-id before ‘.’ token
/home/paulbremner/install/ASPECT/aspect/devel/source/material_model/interface.cc:760:1: error: expected ‘}’ at end of input
}
^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That can't be it -- you have a function argument above that's called fe
. Did you rename it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't believe so. The line right above this one uses fe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So do you have any changes in your local version right now compared to the version in the pull request?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but only changes to address the comments from Ian.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only code changes (as in not a comment change) are this one being discussed, and deleting the line discussed in Ian's next comment.
source/material_model/interface.cc
Outdated
fe[introspection.extractors.pressure].get_function_values (solution_vector, this->pressure); | ||
fe[introspection.extractors.pressure].get_function_gradients (solution_vector, this->pressure_gradient); | ||
|
||
std::vector<SymmetricTensor<2,dim> > strain_rate (fe.n_quadrature_points); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That isn't used... deleting line
source/material_model/interface.cc
Outdated
for (unsigned int c=0; c<introspection.n_compositional_fields; ++c) | ||
this->composition[i][c] = composition_values[c][i]; | ||
} | ||
//********************************** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove comment.
/run-tests |
004dbf5
to
9bb7b00
Compare
|
||
/** | ||
* Constructor. Both initialize and populate the various arrays of this | ||
* structure with the finite element and introspection objects and the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's not actually the "finite element", but the "FEValues" object
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done as suggested.
/** | ||
* Constructor. Both initialize and populate the various arrays of this | ||
* structure with the finite element and introspection objects and the | ||
* the solution_vector. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the the -> the
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
fe_values[introspection.extractors.velocities].get_function_values (solution_vector, this->velocity); | ||
fe_values[introspection.extractors.pressure].get_function_values (solution_vector, this->pressure); | ||
fe_values[introspection.extractors.pressure].get_function_gradients (solution_vector, this->pressure_gradient); | ||
fe_values[introspection.extractors.velocities].get_function_symmetric_gradients (solution_vector,this->strain_rate); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the last line is going to be an interesting one to consider. I don't think that all potential calling sites for this function do populate the strain_rate
variable.
We should watch this in the places where we replace existing code by your function to see whether we need to modify this function further. The same is probably true for the gradient of the pressure, which is also not necessary everywhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way to make this function smart enough to only populate the necessary arrays?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only by passing a whole bunch of bool
arguments that indicate what is or isn't necessary to do. I would suggest leaving it as is for the moment (but undoing the change in nullspace.cc
) and then carefully looking at each place where we want to call this function whether we are doing more than necessary or not -- and if yes, think about what to do next.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could add additional bool
flags to the constructor. It would get fairly busy at that point. Is it strictly reasonable to assume that a material model does not require something like strain rates or pressure gradients? They were added to MaterialModelInputs
for a reason.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like when we exclude the strain rates, we are implicitly making the assumption that we don't require the viscosity in the outputs, and strain rate only has an effect on the viscosity. This is probably not true in general. For instance, there are some dilational materials that change density upon shearing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not clear what you mean. If the strain rate is not filled, then the calling place explicitly doesn't want the viscosity. And because the strain rate vector is filled with signaling nans or has size zero, its contents can also not be used by accident. So I can't see a case where a place forgets to fill the strain rate but then accidentally uses the computed viscosity anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am thinking of a case where some of the other material model outputs (such as density) may depend on strain rates. In which case those material models would fail if strain_rate is not passed in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I misread thinking that you were talking about the viscosity depending on strain rate, not density. I agree. Rock for example is such a material: if you shear it enough, you get sand that takes more volume than the original rock.
Nothing that can be done about this right now -- this simply isn't supported. I seem to recall that the reason we did it that way was that it is expensive to (i) evaluate the strain rate tensors, and (ii) to evaluate the viscosities, so we avoided it when possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this is an issue for a different PR :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now I left the function as is, but I reverted nullspace.cc back to it's original form and I now test the function call in source/simulator/lateral_averaging.cc instead.
source/material_model/interface.cc
Outdated
fe_values[introspection.extractors.pressure].get_function_gradients (solution_vector, this->pressure_gradient); | ||
fe_values[introspection.extractors.velocities].get_function_symmetric_gradients (solution_vector,this->strain_rate); | ||
|
||
//Vectors for evaluating the finite element solution |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add a space: // vectors...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also maybe say "...the compositional field parts of the finite element solution"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
source/material_model/interface.cc
Outdated
} | ||
|
||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need for these empty lines
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
source/simulator/nullspace.cc
Outdated
} | ||
in.cell = &cell; | ||
|
||
material_model->evaluate(in, out); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this change doesn't look right. you used to call material_model->evaluate()
before, but now you no longer do.
In fact, this may not be the very best place to test your changes. We really only need anything other than the velocities in in
if use_constant_density == false
. You now do substantially more work here by populating all of the fields (and adding back the now missing call to evaluate
).
Maybe the best way to deal with this would be to leave this one place as it was before (can also easily be done with git) and pick a different place where we initialize a MaterialModelInputs
object to test your new code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nullspace.cc has been reverted back to it's original form. I have tested this new call in source/simulator/lateral_averaging.cc instead. The test passed. I have updated the commit message accordingly.
This patch adds a new MaterialModel array constructor that both initializes and populates the MaterialModel arrays. The old constructor only sizes the arrays, then the arrays must be populated within the calling function. This constructor streamlines how these array values are obtained by making a single standard call to the constructor. This patch is now called in source/simulator/lateral_averaging.cc to test.
9bb7b00
to
cdcb02c
Compare
OK to merge if the tester is happy. |
This patch adds a new MaterialModel array constructor that both initializes
and populates the MaterialModel arrays. The old constructor only sizes
the arrays, then the arrays must be populated within the calling function.
This constructor streamlines how these array values are obtained by making
a single standard call to the constructor. This patch is now called in
nullspace.cc to test.