Skip to content
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

Extra functionality of Tensor class #631

Merged
merged 1 commit into from Mar 2, 2015
Merged

Extra functionality of Tensor class #631

merged 1 commit into from Mar 2, 2015

Conversation

@davydden
Copy link
Member

davydden commented Mar 2, 2015

the two commits are currently part of https://github.com/dealii/dealii/pull/621/commits
Wolfang wanted at least one of them to be in separate PR, thus I create it.

inline
Number contract (const Tensor<1,dim,Number> &src1,
const Tensor<1,dim,Number> &src2)
const Tensor<1,dim,OtherNumber> &src2)

This comment has been minimized.

Copy link
@bangerth

bangerth Mar 2, 2015

Member

The return type of this should now be typename ProductType<Number,OtherNumber>::type. Same in the operator*.

* where the scalar is of the same base type and
* T is a symmetric tensor of double.
*/
void add(const Number &a, const SymmetricTensor<rank,dim,double> &p);

This comment has been minimized.

Copy link
@bangerth

bangerth Mar 2, 2015

Member

Why only add SymmetricTensor<rank,dim,double> and not SymmetricTensor<rank,dim,Number>?

This comment has been minimized.

Copy link
@davydden

davydden Mar 2, 2015

Author Member

that was used to add to the resulting tensor a number multiplied by the tensor object coming from the shape functions, thus double only

@bangerth
Copy link
Member

bangerth commented Mar 2, 2015

I don't recall the conversation about this. Where do you need the add functions?

@davydden
Copy link
Member Author

davydden commented Mar 2, 2015

There was no conversation about the add function, but I use it heavily in the PR cited above, see davydden@2e30cc3

@davydden
Copy link
Member Author

davydden commented Mar 2, 2015

I think add() shall be quicker than something like

derivatives[q_point] += value *
typename ProductType<Number,dealii::Tensor<order,spacedim> >::type(*shape_derivative_ptr++);

as it shall not require a temporary object.

@bangerth
Copy link
Member

bangerth commented Mar 2, 2015

This is for small objects with a handful of elements. The compiler will optimize all of this out -- let's not worry about these micro-optimizations unless we have evidence that they are necessary.

So I would vote to just leave the existing code of the form

derivatives[q_point] += value *
typename ProductType<Number,dealii::Tensor<order,spacedim> >::type(*shape_derivative_ptr++);

in place. There is a cost to adding member functions (as this discussion shows) and it doesn't seem worth it at this point.

@davydden
Copy link
Member Author

davydden commented Mar 2, 2015

ok

@davydden davydden force-pushed the davydden:tensor branch from d5977f8 to f99b04b Mar 2, 2015
@davydden
Copy link
Member Author

davydden commented Mar 2, 2015

will check that it compiles...

@davydden
Copy link
Member Author

davydden commented Mar 2, 2015

builds fine.

@bangerth
Copy link
Member

bangerth commented Mar 2, 2015

Looks good.

bangerth added a commit that referenced this pull request Mar 2, 2015
Extra functionality of Tensor class
@bangerth bangerth merged commit e71080c into dealii:master Mar 2, 2015
1 check passed
1 check passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@davydden
Copy link
Member Author

davydden commented Feb 21, 2016

in reference to #2033

@davydden davydden deleted the davydden:tensor branch May 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.