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

Method ApplyIntegrationPoints

comp/bilinearform.cpp:1096–1187  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1094 */
1095
1096 ApplyIntegrationPoints ::
1097 ApplyIntegrationPoints (Array<shared_ptr<CoefficientFunction>> acoefs,
1098 const Array<ProxyFunction*> & atrialproxies,
1099 Matrix<> apoints, Matrix<> anormals,
1100 size_t adimx, size_t adimy, size_t anip)
1101 : coefs(acoefs), trialproxies{atrialproxies}, dimx(adimx), dimy(adimy), nip(anip),
1102 points(std::move(apoints)), normals(std::move(anormals))
1103 {
1104 // make my own code
1105
1106 Array<int> proxyoffset;
1107 int starti = 0;
1108 for (auto proxy : trialproxies)
1109 {
1110 proxyoffset.Append (starti);
1111 starti += proxy->Evaluator()->Dim();
1112 }
1113
1114 stringstream s;
1115 s <<
1116 "#include <cstddef>\n"
1117 "extern \"C\" void ApplyIPFunction (size_t nip, double * input, size_t dist_input,\n"
1118 " double * output, size_t dist_output,\n"
1119 " size_t dist, double * pnts, double * nvs) {\n";
1120
1121 int base_output = 0;
1122 for (auto cf : coefs)
1123 {
1124 auto compiledcf = Compile (cf, false);
1125 Code code = compiledcf->GenerateProgram(0, false);
1126
1127 s << "{\n";
1128 // cout << code.header << endl;
1129
1130 for (auto step : Range(compiledcf->Steps()))
1131 if (auto proxycf = dynamic_cast<ProxyFunction*> (compiledcf->Steps()[step]))
1132 if (auto pos = trialproxies.Pos(proxycf); pos != trialproxies.ILLEGAL_POSITION)
1133 {
1134 s << "auto values_" << step << " = [dist_input,input](size_t i, int comp)\n"
1135 " { return input[i + (comp+" << proxyoffset[pos] << ")*dist_input]; };\n";
1136 s << "bool constexpr has_values_" << step << " = true;\n" << endl;
1137 // Declare dummy com_ variables to avoid compile errors (won't be used since has_values = true)
1138 for(auto i : Range(proxycf->Dimension()))
1139 s << Var("comp", step,i, proxycf->Dimensions()).Declare("double", 0.0);
1140 }
1141
1142 s << "[[maybe_unused]] auto points = [dist,pnts](size_t i, int comp)\n"
1143 " { return pnts[i+comp*dist]; };\n";
1144 s << "[[maybe_unused]] auto normals = [dist,nvs](size_t i, int comp)\n"
1145 " { return nvs[i+comp*dist]; };\n";
1146
1147 s << "for (size_t i = 0; i < nip; i++) {\n";
1148 s << code.body << endl;
1149
1150 // missing: last step nr
1151 for (int j = 0; j < cf->Dimension(); j++)
1152 s << "output[i+"<<base_output+j<<"*dist_output] = "
1153 << Var(compiledcf->Steps().Size()-1, j, cf->Dimensions()).code << ";\n";

Callers

nothing calls this directly

Calls 11

CompileFunction · 0.85
VarFunction · 0.85
CreateTempDirFunction · 0.85
GenerateProgramMethod · 0.80
DeclareMethod · 0.80
DimensionsMethod · 0.80
RangeFunction · 0.50
AppendMethod · 0.45
DimMethod · 0.45
DimensionMethod · 0.45
SizeMethod · 0.45

Tested by

no test coverage detected