6 #include "GmshConfig.h"
20 {
GMSH_FULLRC,
"Resuling View Name",
nullptr,
"default"}};
31 return "Plugin(Summation) sums every time steps "
32 "of 'Reference View' and (every) 'Other View X'"
33 "and store the result in a new view.\n"
34 "If 'View 0' < 0 then the current view is selected.\n"
35 "If 'View 1...8' < 0 then this view is skipped.\n"
36 "Views can have different number of time steps\n"
37 "Warning: the Plugin assume that every views share"
38 "the same mesh and that meshes do not move between time steps!";
64 std::vector<int> views_indices;
65 std::vector<PView *> pviews;
66 std::vector<PViewData *> pviewsdata;
69 for(
int i = 0; i < nviewmax; i++) {
71 if(i == 0 || iview > -1) {
72 views_indices.push_back(iview);
73 pviews.push_back(
getView(iview, view));
75 Msg::Error(
"Summation plugin could not find view %i", iview);
79 if(pviewsdata.back()->hasMultipleMeshes()) {
80 Msg::Error(
"Summation plugin cannot be applied to multi-mesh views");
86 int nviews = pviews.size();
90 for(
int j = 1; j < nviews; j++) {
91 if(pviewsdata[j]->getNumEntities() == 0 &&
92 pviewsdata[j]->getNumElements() == 0)
94 if((pviewsdata[0]->getNumEntities() != pviewsdata[j]->getNumEntities()) ||
95 (pviewsdata[0]->getNumElements() != pviewsdata[j]->getNumElements())) {
96 Msg::Error(
"Summation plugin: views based on different grid.");
100 int timeBeg = pviewsdata[0]->getFirstNonEmptyTimeStep();
101 int timeEnd = pviewsdata[0]->getNumTimeSteps();
103 int stepref = timeBeg;
104 for(
int i = 1; i < nviews; i++) {
105 if(timeBeg > pviewsdata[i]->getFirstNonEmptyTimeStep()) {
106 timeBeg = pviewsdata[i]->getFirstNonEmptyTimeStep();
110 timeEnd = std::max(timeEnd, pviewsdata[i]->getNumTimeSteps());
116 for(
int ent = 0; ent < pviewsdata[iref]->getNumEntities(stepref); ent++) {
117 for(
int ele = 0; ele < pviewsdata[iref]->getNumElements(stepref, ent);
120 int numNodes = pviewsdata[iref]->getNumNodes(stepref, ent, ele);
121 int type = pviewsdata[iref]->getType(stepref, ent, ele);
122 int numComp = pviewsdata[iref]->getNumComponents(stepref, ent, ele);
123 int numComp2 = numComp;
124 std::vector<double> *out = data2->
incrementList(numComp2, type, numNodes);
125 std::vector<double> v(std::max(9, numComp), 0.);
126 std::vector<double> x(numNodes), y(numNodes),
z(numNodes);
127 for(
int nod = 0; nod < numNodes; nod++)
128 pviewsdata[iref]->getNode(stepref, ent, ele, nod, x[nod], y[nod],
130 for(
int nod = 0; nod < numNodes; nod++) out->push_back(x[nod]);
131 for(
int nod = 0; nod < numNodes; nod++) out->push_back(y[nod]);
132 for(
int nod = 0; nod < numNodes; nod++) out->push_back(
z[nod]);
133 for(
int step = timeBeg; step < timeEnd; step++) {
134 for(
int nod = 0; nod < numNodes; nod++) {
135 for(
int comp = 0; comp < numComp; comp++) {
137 for(
int iview = 0; iview < nviews; iview++) {
138 if(!pviewsdata[iview]->hasTimeStep(step))
continue;
140 pviewsdata[iview]->getValue(step, ent, ele, nod, comp, d);
144 for(
int i = 0; i < numComp2; i++) out->push_back(v[i]);
151 for(
int step = timeBeg; step < timeEnd; step++) {
153 for(iview = 0; iview < nviews; iview++) {
154 if(!pviewsdata[iview]->hasTimeStep(step))
continue;
157 data2->
Time.push_back(pviewsdata[iview]->getTime(step));
161 if(outputname ==
"default")
162 outputname = pviewsdata[0]->getName() +
"_Summation";