7 #ifndef __spatial_Continuum_h__ 8 #define __spatial_Continuum_h__ 25 virtual ~Continuum(
void)
29 Continuum<T> &operator=(
const Continuum<T> &a_other)
31 m_unitContinuum = a_other.m_unitContinuum;
32 m_space = a_other.m_space;
38 if(m_unitContinuum != a_other.m_unitContinuum)
42 if(m_space != a_other.m_space)
49 typedef typename UnitContinuum<T,3>::t_index t_index;
50 typedef typename UnitContinuum<T,3>::t_cells t_cells;
51 typedef SpaceI t_space;
53 void create(
const t_index &a_count,
55 const sp<t_space> &a_space);
59 void index( t_index &a_index,
60 const SpatialVector &a_location)
const;
61 void lower( t_index &a_index,
62 const SpatialVector &a_location)
const;
65 void location( SpatialVector &a_location,
66 const t_index &a_index)
const;
69 SpatialVector &safe( SpatialVector &a_location)
const;
70 bool isSafe(
const SpatialVector &a_location)
const;
73 const UnitContinuum<T,3> &unit(
void)
const;
74 UnitContinuum<T,3> &accessUnit(
void);
76 sp<t_space> &space(
void) {
return m_space; }
78 void cellsize(SpatialVector &a_cellsize);
82 UnitContinuum<T,3> m_unitContinuum;
87 inline void Continuum<T>::create(
const t_index &a_count,
const T &a_init,
88 const sp<t_space> &a_space)
90 m_unitContinuum.create(a_count, a_init);
96 inline void Continuum<T>::index(t_index &a_index,
97 const SpatialVector &a_location)
const 99 SpatialVector unit_location;
100 m_space->from(unit_location, a_location);
101 typename UnitContinuum<T,3>::t_span location;
102 location = unit_location;
103 m_unitContinuum.index(a_index, location);
107 inline void Continuum<T>::lower(t_index &a_index,
108 const SpatialVector &a_location)
const 110 SpatialVector unit_location;
111 m_space->from(unit_location, a_location);
112 m_unitContinuum.lower(a_index, unit_location);
116 inline void Continuum<T>::location(SpatialVector &a_location,
117 const t_index &a_index)
const 119 typename UnitContinuum<T,3>::t_span unit_location;
120 m_unitContinuum.location(unit_location, a_index);
121 SpatialVector location = unit_location;
122 m_space->to(a_location, location);
126 inline SpatialVector &Continuum<T>::safe(SpatialVector &a_span)
const 128 SpatialVector unit_span;
129 m_space->from(unit_span, a_span);
130 typename UnitContinuum<T,3>::t_span uspan;
132 m_unitContinuum.safe(uspan);
134 m_space->to(a_span, unit_span);
139 inline bool Continuum<T>::isSafe(
const SpatialVector &a_span)
const 141 SpatialVector unit_span;
142 m_space->from(unit_span, a_span);
143 typename UnitContinuum<T,3>::t_index index, safe_index;
144 typename UnitContinuum<T,3>::t_span uspan;
146 m_unitContinuum.index(index, uspan);
148 m_unitContinuum.safe(safe_index);
149 return (index == safe_index);
153 inline const UnitContinuum<T,3> &Continuum<T>::unit(
void)
const 155 return m_unitContinuum;
159 inline UnitContinuum<T,3> &Continuum<T>::accessUnit(
void)
161 return m_unitContinuum;
165 inline void Continuum<T>::cellsize(SpatialVector &a_cellsize)
167 typename UnitContinuum<T,3>::t_span unitsz = unit().cellsize();
168 SpatialVector origin(0.0,0.0,0.0);
171 m_space->to(origin, origin);
172 m_space->to(a_cellsize, sz);
173 a_cellsize -= origin;
183 const T &directSample(
const Continuum<T> &a_continuum,
184 const SpatialVector &a_location)
186 typename Continuum<T>::t_index idx;
187 a_continuum.index(idx, a_location);
188 return a_continuum.unit()[idx];
195 void gradient(Continuum<Real> &a_continuum, SpatialVector &a_gradient,
196 const SpatialVector &a_location, Real a_h = 0.1);
198 struct t_n_radial_set
200 SpatialVector *m_location;
201 SpatialVector *m_radius;
202 Continuum<Real> *m_continuum;
206 void rad_func(UnitContinuum<Real,3> &a_unit,
207 UnitContinuum<Real,3>::t_index &a_index, t_n_radial_set *a_data);
211 FE_DL_EXPORT
void radialSet(Continuum<Real> &a_continuum,
212 const SpatialVector &a_location,
213 const SpatialVector &a_radius, Real a_value);
218 void derive(Continuum<T> &a_vector, Continuum<Real> &a_scalar)
220 derive<T,3>(a_vector.accessUnit(), a_scalar.accessUnit());
221 a_vector.space() = a_scalar.space();
232 template<
typename T,
unsigned int D>
239 virtual ~Continuum(
void)
243 Continuum<T,D> &operator=(
const Continuum<T,D> &other)
245 m_origin = other.m_origin;
246 m_count = other.m_count;
247 for(
unsigned int i = 0; i < D; i++)
249 m_boundary[i] = other.m_boundary[i];
250 m_size[i] = other.m_size[i];
252 m_cells = other.m_cells;
253 m_totalCount = other.m_totalCount;
259 if(m_origin != other.m_origin) {
return false; }
260 if(m_count != other.m_count) {
return false; }
261 if(m_boundary != other.m_boundary) {
return false; }
262 if(m_size != other.m_size) {
return false; }
263 if(m_totalCount != other.m_totalCount) {
return false; }
264 if(m_cells == other.m_cells) {
return true; }
268 template <
typename P>
269 void copyTopology(
const Continuum<P,D> &a_other,
272 create(a_other.m_count, a_other.m_boundary, a_init);
275 typedef Vector<D,int> t_index;
276 typedef Vector<D,Real> t_span;
277 typedef std::vector<T> t_cells;
279 void create(
const t_index &a_count,
280 const t_span &a_boundary,
283 void create(
const t_span &a_origin,
284 const t_index &a_count,
285 const t_span &a_boundary,
288 const T &operator[](
const t_index &a_index)
const;
290 void set(
const t_index &a_index,
const T &value);
291 void set(
const T &value);
292 T &access(
const t_index &a_index);
294 void direct( t_index &a_direct,
295 const t_span &a_location)
const;
296 void closest( t_index &a_closest,
297 const t_span &a_location)
const;
298 void space( t_span &a_space,
299 const t_index &a_index)
const;
300 const t_span &cellsize(
void)
const {
return m_size; }
301 const t_index &count(
void)
const {
return m_count; }
302 const t_span &origin(
void)
const {
return m_origin; }
303 const t_span &boundary(
void)
const {
return m_boundary; }
304 unsigned int totalCount(
void)
const {
return m_totalCount; }
308 void iterate(
void (*a_function)(Continuum<T,D> &,
314 std::list<t_index> &a_neighbors,
315 const t_index &a_index)
const;
316 void addNeighborsDiagonal(
317 std::list<t_index> &a_neighbors,
318 const t_index &a_index)
const;
319 t_index &safe( t_index &a_index)
const;
320 t_span &safe( t_span &a_span)
const;
322 bool safe(
unsigned int a_i,
323 t_index &a_index)
const;
324 void addNeighborsD(
unsigned int a_d,
325 std::list<t_index> &a_neighbors,
326 const t_index &a_index,
327 const t_index &a_base)
const;
328 unsigned int calc_array_index(
const t_index &a_index)
const;
330 void rIterate(
unsigned int a_d,
332 void (*a_function)(Continuum<T,D> &,
343 unsigned int m_totalCount;
346 template<
typename T,
unsigned int D>
347 inline bool Continuum<T,D>::safe(
unsigned int a_i, t_index &a_index)
const 350 if(m_count[a_i] == 1)
352 if(a_index[a_i] != 0)
354 if(m_boundary[a_i] >= 0.0)
361 else if(m_count[a_i] == 2)
365 if(m_boundary[a_i] >= 0.0)
371 else if(a_index[a_i] > 1)
373 if(m_boundary[a_i] >= 0.0)
382 while(a_index[a_i] < 0)
384 if(m_boundary[a_i] < 0.0)
386 a_index[a_i] += m_count[a_i] - 1;
394 while(a_index[a_i] >= m_count[a_i])
396 if(m_boundary[a_i] < 0.0)
398 a_index[a_i] -= m_count[a_i] - 1;
403 a_index[a_i] = m_count[a_i]-1;
411 template<
typename T,
unsigned int D>
412 inline typename Continuum<T,D>::t_index &Continuum<T,D>::safe(t_index &a_index)
const 414 for(
unsigned int i = 0; i < D; i++)
420 else if(m_count[i] == 2)
426 else if(a_index[i] > 1)
433 while(a_index[i] < 0)
435 if(m_boundary[i] < 0.0)
437 a_index[i] += m_count[i] - 1;
444 while(a_index[i] >= m_count[i])
446 if(m_boundary[i] < 0.0)
448 a_index[i] -= m_count[i] - 1;
452 a_index[i] = m_count[i]-1;
461 template<
typename T,
unsigned int D>
462 inline typename Continuum<T,D>::t_span &Continuum<T,D>::safe(
463 t_span &a_span)
const 466 for(
unsigned int i = 0; i < D; i++)
474 Real bnd = fabs(m_boundary[i]);
475 while(a_span[i] < 0.0)
477 if(m_boundary[i] < 0.0)
486 while(a_span[i] > bnd)
488 if(m_boundary[i] < 0.0)
504 template<
typename T,
unsigned int D>
506 inline void Continuum<T,D>::iterate(
void (*a_function)(Continuum<T,D> &,
507 t_index &, A), A a_userarg)
510 rIterate(D-1, index, a_function, a_userarg);
513 template<
typename T,
unsigned int D>
515 inline void Continuum<T,D>::rIterate(
unsigned int a_d, t_index &a_index,
516 void (*a_function)(Continuum<T,D> &, t_index &, A), A a_userarg)
518 for(
int i = 0; i < count()[a_d]; i++)
523 a_function(*
this, a_index, a_userarg);
527 rIterate(a_d-1, a_index, a_function, a_userarg);
533 template<
typename T,
unsigned int D>
534 inline void Continuum<T,D>::direct(t_index &a_index,
535 const t_span &a_location)
const 537 t_span location = a_location - m_origin;
538 for(
int i = D-1; i >= 0; i--)
542 a_index[i] = (int)(location[i] / m_size[i]);
549 if(a_index[i] >= m_count[i] - 1)
551 a_index[i] = m_count[i] - 2;
560 template<
typename T,
unsigned int D>
561 inline void Continuum<T,D>::closest(t_index &a_index,
562 const t_span &a_location)
const 564 t_span location = a_location - m_origin;
565 for(
int i = D-1; i >= 0; i--)
569 a_index[i] = (int)((location[i]+(0.5*m_size[i])) / m_size[i]);
576 if(a_index[i] >= m_count[i])
578 a_index[i] = m_count[i] - 1;
587 template<
typename T,
unsigned int D>
588 inline unsigned int Continuum<T,D>::calc_array_index(
589 const t_index &a_index)
const 591 unsigned int index = 0;
592 unsigned int step = 1;
593 for(
int d = D-1; d >= 0; d--)
595 index += a_index[d] * step;
602 template<
typename T,
unsigned int D>
603 inline void Continuum<T,D>::space(t_span &a_space,
const t_index &a_index)
const 605 for(
unsigned int i = 0; i < D; i++)
607 a_space[i] = (Real)a_index[i] * cellsize()[i] + m_origin[i];
611 template<
typename T,
unsigned int D>
612 inline void Continuum<T,D>::create(
const t_index &a_count,
613 const t_span &a_boundary,
const T &a_init)
616 for(
unsigned int i = 0; i < D; i++)
618 m_boundary[i] = a_boundary[i];
619 m_count[i] = a_count[i];
620 Real bnd = fabs(m_boundary[i]);
627 m_size[i] = bnd / (m_count[i] - 1);
629 m_totalCount *= m_count[i];
632 m_cells.resize(m_totalCount, a_init);
635 template<
typename T,
unsigned int D>
636 inline void Continuum<T,D>::create(
const t_span &a_origin,
637 const t_index &a_count,
638 const t_span &a_boundary,
const T &a_init)
641 create(a_count, a_boundary, a_init);
645 template<
typename T,
unsigned int D>
646 inline const T &Continuum<T,D>::operator[](
const t_index &a_index)
const 648 return m_cells[calc_array_index(a_index)];
651 template<
typename T,
unsigned int D>
652 inline T &Continuum<T,D>::access(
const t_index &a_index)
654 return m_cells[calc_array_index(a_index)];
657 template<
typename T,
unsigned int D>
658 inline void Continuum<T,D>::set(
const t_index &a_index,
const T &a_value)
660 m_cells[calc_array_index(a_index)] = a_value;
663 template<
typename T,
unsigned int D>
664 inline void Continuum<T,D>::set(
const T &a_value)
666 for(
unsigned int i = 0; i < m_cells.size(); i++)
668 m_cells[i] = a_value;
672 template<
typename T,
unsigned int D>
673 inline void Continuum<T,D>::addNeighborsD(
unsigned int a_d,
674 std::list<t_index> &a_neighbors,
const t_index &a_index,
675 const t_index &a_base)
const 677 t_index candidate = a_index;
680 candidate[a_d] = a_index[a_d] + 1;
681 if(safe(a_d, candidate))
683 if(!(candidate == a_base))
685 a_neighbors.push_back(candidate);
689 candidate[a_d] = a_index[a_d] - 1;
690 if(safe(a_d, candidate))
692 if(!(candidate == a_base))
694 a_neighbors.push_back(candidate);
698 candidate[a_d] = a_index[a_d];
699 if(safe(a_d, candidate))
701 if(!(candidate == a_base))
703 a_neighbors.push_back(candidate);
709 candidate[a_d] = a_index[a_d] + 1;
710 safe(a_d, candidate);
711 if(candidate[a_d] != a_index[a_d])
713 addNeighborsD(a_d-1, a_neighbors, candidate, a_base);
716 candidate[a_d] = a_index[a_d] - 1;
717 safe(a_d, candidate);
718 if(candidate[a_d] != a_index[a_d])
720 addNeighborsD(a_d-1, a_neighbors, candidate, a_base);
723 candidate[a_d] = a_index[a_d];
724 safe(a_d, candidate);
725 addNeighborsD(a_d-1, a_neighbors, candidate, a_base);
731 template<
typename T,
unsigned int D>
732 inline void Continuum<T,D>::addNeighborsDiagonal(
733 std::list<t_index> &a_neighbors,
const t_index &a_index)
const 735 t_index candidate = a_index;
737 if(!(candidate == a_index))
739 feX(
"Continuum<T,D>::addNeighbors",
740 "invalid reference index");
742 addNeighborsD(D-1, a_neighbors, candidate, a_index);
745 template<
typename T,
unsigned int D>
746 inline void Continuum<T,D>::addNeighbors(std::list<t_index> &a_neighbors,
747 const t_index &a_index)
const 749 t_index candidate = a_index;
751 if(!(candidate == a_index))
753 feX(
"Continuum<T,D>::addNeighbors",
754 "invalid reference index");
756 for(
unsigned int i = 0; i < D; i++)
758 candidate[i] = a_index[i] + 1;
760 if(candidate[i] != a_index[i])
762 a_neighbors.push_back(candidate);
765 candidate[i] = a_index[i] - 1;
767 if(candidate[i] != a_index[i])
769 a_neighbors.push_back(candidate);
772 candidate[i] = a_index[i];
777 template<
typename T,
unsigned int D>
778 inline typename Continuum<T,D>::t_span Continuum<T,D>::locate(
779 const t_index &a_index)
const 781 typename Continuum<T,D>::t_span location;
782 space(location, a_index);
797 template<
typename T,
unsigned int D>
798 const T &directSample(
const Continuum<T,D> &a_continuum,
799 const typename Continuum<T,D>::t_span &a_location)
801 typename Continuum<T,D>::t_index direct;
802 a_continuum.direct(direct, a_location);
803 return a_continuum[direct];
808 template<
typename T,
unsigned int D>
809 const T &closestSample(
const Continuum<T,D> &a_continuum,
810 const typename Continuum<T,D>::t_span &a_location)
812 typename Continuum<T,D>::t_index closest;
813 a_continuum.closest(closest, a_location);
814 a_continuum[closest];
815 return a_continuum[closest];
824 template<
unsigned int D>
825 Real rLinearSample(
unsigned int a_d,
const Continuum<Real,3> &a_continuum,
826 typename Continuum<Real,D>::t_index &a_index,
827 typename Continuum<Real,D>::t_index &a_direct,
float a_mult,
832 a_index[a_d] = a_direct[a_d];
833 a_continuum.safe(a_index);
834 m = a_bnd[a_d].m_hi * a_mult;
839 accum += m * a_continuum[a_index];
843 accum += rLinearSample<D>(a_d-1, a_continuum, a_index, a_direct,
848 a_index[a_d] = a_direct[a_d] + 1;
849 a_continuum.safe(a_index);
850 m = a_bnd[a_d].m_lo * a_mult;
855 accum += m * a_continuum[a_index];
859 accum += rLinearSample<D>(a_d-1, a_continuum, a_index, a_direct,
871 template<
unsigned int D>
872 Real linearSample(
const Continuum<Real,D> &a_continuum,
873 const typename Continuum<Real,D>::t_span &a_location)
877 typename Continuum<Real,D>::t_index direct;
878 a_continuum.direct(direct, a_location);
880 typename Continuum<Real,D>::t_span location =
881 a_location - a_continuum.origin();
883 for(
unsigned int i = 0; i < D; i++)
885 if(a_continuum.cellsize()[i] == 0.0)
892 bnd[i].m_lo = location[i]/a_continuum.cellsize()[i] -
895 bnd[i].m_hi = 1.0 - bnd[i].m_lo;
901 typename Continuum<Real,D>::t_index index;
902 return rLinearSample<D>(D-1, a_continuum, index, direct, r, bnd);
906 template<
unsigned int D>
907 Real rPolySample(
unsigned int a_d,
908 const Continuum<Real,3> &a_continuum,
909 const typename Continuum<Real,D>::t_span &a_location,
910 typename Continuum<Real,D>::t_index &a_index,
911 typename Continuum<Real,D>::t_index &a_direct,
912 const typename Continuum<Real,D>::t_index &a_block)
915 int size = a_block[a_d];
916 int minus = (size / 2) - 1;
917 if(minus < 0) { minus = 0; }
920 if((
int)a_direct[a_d] < minus)
922 pre = minus - a_direct[a_d];
924 minus = a_direct[a_d];
926 int root = (int)a_direct[a_d] - minus;
927 if(root + size > (
int)a_continuum.count()[a_d])
929 post = size - (a_continuum.count()[a_d] - root);
930 size = a_continuum.count()[a_d] - root;
933 if(size < 1) { size = 1; }
935 std::vector<Vector<2,Real> > xy(size+pre+post);
936 for(
int i = 0; i < size; i++)
938 a_index[a_d] = root + i;
940 xy[i+pre][0] = a_continuum.cellsize()[a_d] * (Real)(root + i);
943 xy[i+pre][1] = a_continuum[a_index];
947 xy[i+pre][1] = rPolySample<D>( a_d-1,
955 for(
int i = 0; i < pre; i++)
957 xy[i][0] = a_continuum.cellsize()[a_d] * (Real)(i - pre);
958 xy[i][1] = xy[pre][1];
960 for(
int i = 0; i < post; i++)
962 xy[size+pre+i][0] = a_continuum.cellsize()[a_d] * (Real)(i + size + root);
963 xy[size+pre+i][1] = xy[size+pre-1][1];
967 polyInterp<Real>(xy,a_location[a_d],y,dy);
973 template<
unsigned int D>
974 Real polySample(
const Continuum<Real,D> &a_continuum,
975 const typename Continuum<Real,D>::t_span &a_location,
976 const typename Continuum<Real,D>::t_index &a_block)
978 typename Continuum<Real,D>::t_index index;
979 typename Continuum<Real,D>::t_index direct;
980 a_continuum.direct(direct, a_location);
981 typename Continuum<Real,D>::t_span location =
982 a_location - a_continuum.origin();
983 return rPolySample<D>( D-1,
993 template<
unsigned int D>
994 Real polySample(
const Continuum<Real,D> &a_continuum,
995 const typename Continuum<Real,D>::t_span &a_location)
997 typename Continuum<Real,D>::t_index block;
998 for(
unsigned int i = 0; i < D; i++)
1000 if(a_continuum.count()[i] < 4)
1002 block[i] = a_continuum.count()[i];
1009 return polySample(a_continuum, a_location, block);
1012 template<
unsigned int D>
1015 typename Continuum<Real,D>::t_span *m_location;
1016 typename Continuum<Real,D>::t_span *m_radius;
1020 template<
unsigned int D>
1021 void rad_func(Continuum<Real,D> &a_continuum,
typename Continuum<Real,D>::t_index &a_index, t_radial_set<D> *a_data)
1024 typename Continuum<Real,D>::t_span index_loc;
1025 a_continuum.space(index_loc, a_index);
1026 for(
unsigned int i = 0; i < D; i++)
1028 Real dist = fabs(index_loc[i] - (*(a_data->m_location))[i]);
1029 if(a_continuum.boundary()[i] < 0.0)
1031 if(dist > fabs(a_continuum.boundary()[i]) / 2.0)
1033 dist = fabs(a_continuum.boundary()[i]) - dist;
1036 dist /= (*(a_data->m_radius))[i];
1038 if(dist > 1.0)
return;
1041 value = 1.0-sqrt(value);
1042 if(value < 0.0)
return;
1043 value = a_data->m_value*value;
1044 a_continuum.set(a_index, value);
1049 template<
unsigned int D>
1050 void radialSet(Continuum<Real,D> &a_continuum,
1051 const typename Continuum<Real,D>::t_span &a_location,
1052 const typename Continuum<Real,D>::t_span &a_radius, Real a_value)
1054 t_radial_set<D> radial_data;
1055 radial_data.m_location =
1056 const_cast<typename Continuum<Real,D>::t_span *
>(&a_location);
1057 radial_data.m_radius =
1058 const_cast<typename Continuum<Real,D>::t_span *
>(&a_radius);
1059 radial_data.m_value = a_value;
1060 a_continuum.iterate(rad_func<D>, &radial_data);
1067 template<
unsigned int D>
1068 void gradientMidPoly(Continuum<Real,D> &a_continuum,
1069 typename Continuum<Real,D>::t_span &a_gradient,
1070 const typename Continuum<Real,D>::t_span &a_location, Real a_h = 0.1)
1072 for(
unsigned int i = 0; i < D; i++)
1074 typename Continuum<Real,D>::t_span lo(a_location);
1075 typename Continuum<Real,D>::t_span hi(a_location);
1078 a_continuum.safe(lo);
1079 a_continuum.safe(hi);
1080 Real lo_smpl = polySample(a_continuum, lo);
1081 Real hi_smpl = polySample(a_continuum, hi);
1082 a_gradient[i] = (hi_smpl - lo_smpl)/(2.0*a_h);
1089 template<
unsigned int D>
1090 void gradientFwdLinear(Continuum<Real,D> &a_continuum,
1091 typename Continuum<Real,D>::t_span &a_gradient,
1092 const typename Continuum<Real,D>::t_span &a_location, Real a_h = 0.1)
1094 for(
unsigned int i = 0; i < D; i++)
1096 typename Continuum<Real,D>::t_span lo(a_location);
1097 typename Continuum<Real,D>::t_span hi(a_location);
1099 a_continuum.safe(lo);
1100 a_continuum.safe(hi);
1101 Real lo_smpl = linearSample(a_continuum, lo);
1102 Real hi_smpl = linearSample(a_continuum, hi);
1103 a_gradient[i] = (hi_smpl - lo_smpl)/(a_h);
1110 template<
unsigned int D>
1111 void gradient(Continuum<Real,D> &a_continuum,
1112 typename Continuum<Real,D>::t_span &a_gradient,
1113 const typename Continuum<Real,D>::t_span &a_location, Real a_h = 0.1)
1115 for(
unsigned int i = 0; i < D; i++)
1117 typename Continuum<Real,D>::t_span lo(a_location);
1118 typename Continuum<Real,D>::t_span hi(a_location);
1121 a_continuum.safe(lo);
1122 a_continuum.safe(hi);
1123 Real lo_smpl = linearSample(a_continuum, lo);
1124 Real hi_smpl = linearSample(a_continuum, hi);
1125 a_gradient[i] = (hi_smpl - lo_smpl)/(2.0*a_h);
1130 template<
typename T,
unsigned int D>
1133 Continuum<T,D> *m_vectors;
1136 template<
typename T,
unsigned int D>
1137 void derive_fun(Continuum<Real,D> &a_continuum,
typename Continuum<Real,D>::t_index &a_index, t_derive<T,D> *a_data)
1139 for(
unsigned int d = 0; d < D; d++)
1141 if(a_continuum.cellsize()[d] > 0.0)
1143 typename Continuum<Real,D>::t_index dn(a_index);
1145 a_continuum.safe(dn);
1146 typename Continuum<Real,D>::t_index up(a_index);
1148 a_continuum.safe(up);
1149 Real value = (a_continuum[up] - a_continuum[dn]) /
1150 (2.0*a_continuum.cellsize()[d]);
1151 setAt(a_data->m_vectors->access(a_index), d, value);
1155 setAt(a_data->m_vectors->access(a_index), d, 0.0f);
1162 template<
typename T,
unsigned int D>
1163 void derive(Continuum<T,D> &a_vector, Continuum<Real,D> &a_scalar)
1166 a_vector.create(a_scalar.count(), a_scalar.boundary(), dummy);
1167 t_derive<T,D> derive_data;
1168 derive_data.m_vectors = &a_vector;
1169 a_scalar.iterate(derive_fun<T,D>, &derive_data);
kernel
Definition: namespace.dox:3
BWORD operator==(const DualString &s1, const DualString &s2)
Compare two DualString's.
Definition: DualString.h:208