51 std::vector<std::vector<T>> fdGrad;
53 fdGrad.resize(_targetDim);
54 for (
int i = 0; i < _targetDim; i++) {
58 for (
int i = 0; i < 3; i++) {
60 fInput_p[0] = input[0];
61 fInput_p[1] = input[1];
62 fInput_p[2] = input[2];
66 fInput_2p[0] = input[0];
67 fInput_2p[1] = input[1];
68 fInput_2p[2] = input[2];
72 fInput_3p[0] = input[0];
73 fInput_3p[1] = input[1];
74 fInput_3p[2] = input[2];
78 fInput_4p[0] = input[0];
79 fInput_4p[1] = input[1];
80 fInput_4p[2] = input[2];
84 fInput_n[0] = input[0];
85 fInput_n[1] = input[1];
86 fInput_n[2] = input[2];
90 fInput_2n[0] = input[0];
91 fInput_2n[1] = input[1];
92 fInput_2n[2] = input[2];
96 fInput_3n[0] = input[0];
97 fInput_3n[1] = input[1];
98 fInput_3n[2] = input[2];
102 fInput_4n[0] = input[0];
103 fInput_4n[1] = input[1];
104 fInput_4n[2] = input[2];
107 T fOutput[_targetDim];
108 _blockFunctor(fOutput,input);
111 if (std::find(_matNumber.begin(), _matNumber.end(), _blockGeometry.get({fInput_2p[0], fInput_2p[1], fInput_2p[2]})) == _matNumber.end()) {
112 T fOutput_p[_targetDim];
113 _blockFunctor(fOutput_p,fInput_p);
114 for (
int j=0; j < _targetDim; j++) {
115 fdGrad[j][i]= -fOutput[j] + fOutput_p[j];
119 T fOutput_p[_targetDim];
120 _blockFunctor(fOutput_p,fInput_p);
121 T fOutput_2p[_targetDim];
122 _blockFunctor(fOutput_2p,fInput_2p);
123 for (
int j=0; j < _targetDim; j++) {
128 else if (input[i] > _n[i]-3) {
129 if (std::find(_matNumber.begin(), _matNumber.end(), _blockGeometry.get({fInput_2n[0], fInput_2n[1], fInput_2n[2]})) == _matNumber.end()) {
130 T fOutput_n[_targetDim];
131 _blockFunctor(fOutput_n,fInput_n);
132 for (
int j=0; j < _targetDim; j++) {
133 fdGrad[j][i]= -fOutput_n[j] + fOutput[j];
137 T fOutput_n[_targetDim];
138 _blockFunctor(fOutput_n,fInput_n);
139 T fOutput_2n[_targetDim];
140 _blockFunctor(fOutput_2n,fInput_2n);
141 for (
int j=0; j < _targetDim; j++) {
147 if ( std::find(_matNumber.begin(), _matNumber.end(), _blockGeometry.get({fInput_n[0], fInput_n[1], fInput_n[2]})) == _matNumber.end() &&
148 std::find(_matNumber.begin(), _matNumber.end(), _blockGeometry.get({fInput_p[0], fInput_p[1], fInput_p[2]})) == _matNumber.end() ) {
149 for (
int j=0; j < _targetDim; j++) {
154 else if (std::find(_matNumber.begin(), _matNumber.end(), _blockGeometry.get({fInput_n[0], fInput_n[1], fInput_n[2]})) == _matNumber.end()) {
155 if (std::find(_matNumber.begin(), _matNumber.end(), _blockGeometry.get({fInput_2p[0], fInput_2p[1], fInput_2p[2]})) == _matNumber.end()) {
156 T fOutput_p[_targetDim];
157 _blockFunctor(fOutput_p,fInput_p);
158 for (
int j=0; j < _targetDim; j++) {
159 fdGrad[j][i]= -fOutput[j] + fOutput_p[j];
163 T fOutput_p[_targetDim];
164 _blockFunctor(fOutput_p,fInput_p);
165 T fOutput_2p[_targetDim];
166 _blockFunctor(fOutput_2p,fInput_2p);
167 for (
int j=0; j < _targetDim; j++) {
172 else if (std::find(_matNumber.begin(), _matNumber.end(), _blockGeometry.get({fInput_p[0], fInput_p[1], fInput_p[2]})) == _matNumber.end() ) {
173 if (std::find(_matNumber.begin(), _matNumber.end(), _blockGeometry.get({fInput_2n[0], fInput_2n[1], fInput_2n[2]})) == _matNumber.end()) {
174 T fOutput_n[_targetDim];
175 _blockFunctor(fOutput_n,fInput_n);
176 for (
int j=0; j < _targetDim; j++) {
177 fdGrad[j][i]= -fOutput_n[j] + fOutput[j];
181 T fOutput_n[_targetDim];
182 _blockFunctor(fOutput_n,fInput_n);
183 T fOutput_2n[_targetDim];
184 _blockFunctor(fOutput_2n,fInput_2n);
185 for (
int j=0; j < _targetDim; j++) {
192 T fOutput_n[_targetDim];
193 _blockFunctor(fOutput_n,fInput_n);
195 T fOutput_2n[_targetDim];
196 _blockFunctor(fOutput_2n,fInput_2n);
198 T fOutput_3n[_targetDim];
199 _blockFunctor(fOutput_3n,fInput_3n);
201 T fOutput_4n[_targetDim];
202 _blockFunctor(fOutput_4n,fInput_4n);
204 T fOutput_p[_targetDim];
205 _blockFunctor(fOutput_p,fInput_p);
207 T fOutput_2p[_targetDim];
208 _blockFunctor(fOutput_2p,fInput_2p);
210 T fOutput_3p[_targetDim];
211 _blockFunctor(fOutput_3p,fInput_3p);
213 T fOutput_4p[_targetDim];
214 _blockFunctor(fOutput_4p,fInput_4p);
215 for (
int j=0; j < _targetDim; j++) {
217 fdGrad[j][i]=((T)672*(fOutput_p[j]-fOutput_n[j])+(T)168*(fOutput_2n[j]-fOutput_2p[j])
218 +(T)32*(fOutput_3p[j]-fOutput_3n[j])+(T)3*(fOutput_4n[j]-fOutput_4p[j])) / 840.;
222 for (
int i=0; i < 3; i++) {
223 for (
int j=0; j < _targetDim; j++) {
224 output[j*3+i] = fdGrad[j][i];
299 for (
int i=0; i<this->getTargetDim(); ++i) {
303 for (
int j=0; j<3; ++j) {
304 inputMod[j] = input[j];
306 T u_0[this->getTargetDim()];
307 T u_m[this->getTargetDim()];
308 T u_p[this->getTargetDim()];
311 T u_2m[this->getTargetDim()];
312 T u_2p[this->getTargetDim()];
315 for (
int j=0; j<3; ++j) {
318 _blockFunctor.operator()(u_m, inputMod);
320 _blockFunctor.operator()(u_0, inputMod);
322 _blockFunctor.operator()(u_p, inputMod);
323 }
else if (input[j] > _n[j]-1) {
325 _blockFunctor.operator()(u_p, inputMod);
327 _blockFunctor.operator()(u_0, inputMod);
329 _blockFunctor.operator()(u_m, inputMod);
332 _blockFunctor.operator()(u_0, inputMod);
334 _blockFunctor.operator()(u_m, inputMod);
336 _blockFunctor.operator()(u_p, inputMod);
338 inputMod[j] = input[j];
340 if ((_forthOrder) && (input[j] > 1) && (input[j] < _n[j]-1)) {
343 _blockFunctor.operator()(u_2m, inputMod);
345 _blockFunctor.operator()(u_2p, inputMod);
346 inputMod[j] = input[j];
349 for (
int i=0; i<this->getTargetDim(); ++i) {
354 for (
int i=0; i<this->getTargetDim(); ++i) {