MCPcopy Create free account
hub / github.com/NGSolve/ngsolve / MakeTensorTraceCoefficientFunction

Function MakeTensorTraceCoefficientFunction

fem/coefficient.cpp:4927–4951  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4925
4926
4927shared_ptr<CoefficientFunction>
4928MakeTensorTraceCoefficientFunction (shared_ptr<CoefficientFunction> c1, int i1, int i2)
4929{
4930 if (i1 < 0 || i1 >= c1->Dimensions().Size())
4931 throw Exception ("TensorTrace, i1 out of range");
4932 if (i2 < 0 || i2 >= c1->Dimensions().Size())
4933 throw Exception ("TensorTrace, i2 out of range");
4934
4935 // a simple workaround for the beginning:
4936 if ( (i1 == 0 && i2 == 1) || (i1 == 1 && i2 == 0) )
4937 {
4938 Array<int> dims1 { c1->Dimensions() };
4939 auto dimsres = dims1.Range(2, END);
4940
4941 // auto shapematT = TransposeCF (ReshapeCF (std::move(c1), sqr(dims1[0]), -1) );
4942 // auto prod = shapematT * ReshapeCF ( IdentityCF(dims1[0]), sqr (dims1[0]) );
4943
4944 auto shapematT = c1 -> Reshape (sqr(dims1[0]), -1) -> Transpose();
4945 auto prod = shapematT * IdentityCF(dims1[0]) -> Reshape (sqr (dims1[0]));
4946
4947 return prod -> Reshape (Array<int> (dimsres));
4948 }
4949
4950 throw Exception("MakeTensorTraceCF not implemented for general case");
4951}
4952
4953
4954

Callers 1

DiffJacobiMethod · 0.85

Calls 4

IdentityCFFunction · 0.85
DimensionsMethod · 0.80
SizeMethod · 0.45
RangeMethod · 0.45

Tested by

no test coverage detected