25 return "Plugin(Integrate) integrates a scalar field over all the elements "
26 "of the view `View' (if `Dimension' < 0), or over all elements of "
27 "the prescribed dimension (if `Dimension' > 0). If the field is a "
28 "vector field, the circulation/flux of the field over line/surface "
29 "elements is calculated.\n\n"
30 "If `View' < 0, the plugin is run on the current view.\n\n"
31 "If `OverTime' = i > -1 , the plugin integrates the scalar view "
32 "over time (using the trapezoidal rule) instead of over space, "
33 "starting at step i. If `Visible' = 1, the plugin only integrates "
34 "over visible entities.\n\n"
35 "Plugin(Integrate) creates one new list-based view.";
66 data2->
SP.push_back(x);
67 data2->
SP.push_back(y);
68 data2->
SP.push_back(
z);
70 double res = 0, resv[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
71 bool simpleSum =
false;
73 if(visible && data1->
skipEntity(step, ent))
continue;
75 if(data1->
skipElement(step, ent, ele, visible))
continue;
78 bool scalar = (numComp == 1);
79 bool circulation = (numComp == 3 && numEdges == 1);
80 bool flux = (numComp == 3 && (numEdges == 3 || numEdges == 4));
84 double x[8], y[8],
z[8], val[8 * 3] = {0.};
85 for(
int nod = 0; nod < numNodes; nod++) {
86 data1->
getNode(step, ent, ele, nod, x[nod], y[nod],
z[nod]);
87 for(
int comp = 0; comp < numComp; comp++)
88 data1->
getValue(step, ent, ele, nod, comp,
89 val[numComp * nod + comp]);
94 for(
int comp = 0; comp < numComp; comp++) resv[comp] += val[comp];
111 Msg::Info(
"Step %d: sum = %g %g %g %g %g %g %g %g %g", step, resv[0],
112 resv[1], resv[2], resv[3], resv[4], resv[5], resv[6], resv[7],
115 Msg::Info(
"Step %d: integral = %.16g", step, res);
116 data2->
SP.push_back(res);
122 double time = data1->
getTime(i);
123 data2->
Time.push_back(time);
130 for(
int ele = 0; ele < data1->
getNumElements(firstStep, ent); ele++) {
131 if(data1->
skipElement(firstStep, ent, ele))
continue;
135 int numNodes = data1->
getNumNodes(firstStep, ent, ele);
136 int type = data1->
getType(firstStep, ent, ele);
139 Msg::Error(
"Can only integrate scalar views over time");
140 std::vector<double> *out =
142 std::vector<double> x(numNodes), y(numNodes),
z(numNodes);
143 for(
int nod = 0; nod < numNodes; nod++)
144 data1->
getNode(firstStep, ent, ele, nod, x[nod], y[nod],
z[nod]);
145 for(
int nod = 0; nod < numNodes; nod++) out->push_back(x[nod]);
146 for(
int nod = 0; nod < numNodes; nod++) out->push_back(y[nod]);
147 for(
int nod = 0; nod < numNodes; nod++) out->push_back(
z[nod]);
149 std::vector<double> val, t;
150 for(
int step = firstStep + overTime; step < numSteps - 1; step++) {
152 t.push_back(data1->
getTime(step));
153 for(
int nod = 0; nod < numNodes; nod++) {
155 data1->
getValue(step, ent, ele, nod, 0, v);
159 std::vector<double> timeIntegral(numNodes, 0.);
160 for(std::size_t step = 0; step < t.size() - 1; step++) {
161 double dt = t[step + 1] - t[step];
162 for(
int nod = 0; nod < numNodes; nod++) {
163 timeIntegral[nod] += 0.5 *
164 (val[step * numNodes + nod] + val[(step + 1) * numNodes + nod]) * dt;
167 for(
int nod = 0; nod < numNodes; nod++)
168 out->push_back(timeIntegral[nod]);