OpenLB 1.7
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
olb::SuperPlaneIntegralF2D< T > Class Template Reference

Surface integral of a subset of a interpolated hyperplane. More...

#include <superPlaneIntegralF2D.h>

+ Inheritance diagram for olb::SuperPlaneIntegralF2D< T >:
+ Collaboration diagram for olb::SuperPlaneIntegralF2D< T >:

Public Member Functions

 SuperPlaneIntegralF2D (FunctorPtr< SuperF2D< T > > &&f, SuperGeometry< T, 2 > &geometry, const HyperplaneLattice2D< T > &hyperplaneLattice, FunctorPtr< SuperIndicatorF2D< T > > &&integrationIndicator, FunctorPtr< IndicatorF1D< T > > &&subplaneIndicator, BlockDataReductionMode mode=BlockDataReductionMode::Analytical)
 Primary constructor.
 
 SuperPlaneIntegralF2D (FunctorPtr< SuperF2D< T > > &&f, SuperGeometry< T, 2 > &geometry, const Hyperplane2D< T > &hyperplane, FunctorPtr< SuperIndicatorF2D< T > > &&integrationIndicator, FunctorPtr< IndicatorF1D< T > > &&subplaneIndicator, BlockDataReductionMode mode=BlockDataReductionMode::Analytical)
 Constructor providing automatic lattice generation.
 
 SuperPlaneIntegralF2D (FunctorPtr< SuperF2D< T > > &&f, SuperGeometry< T, 2 > &geometry, const Hyperplane2D< T > &hyperplane, FunctorPtr< SuperIndicatorF2D< T > > &&integrationIndicator, BlockDataReductionMode mode=BlockDataReductionMode::Analytical)
 Constructor providing automatic lattice generation and omitting subplane restriction.
 
 SuperPlaneIntegralF2D (FunctorPtr< SuperF2D< T > > &&f, SuperGeometry< T, 2 > &geometry, const Vector< T, 2 > &origin, const Vector< T, 2 > &u, std::vector< int > materials, BlockDataReductionMode mode=BlockDataReductionMode::Analytical)
 Constructor providing automatic lattice and material indicator instantiation.
 
 SuperPlaneIntegralF2D (FunctorPtr< SuperF2D< T > > &&f, SuperGeometry< T, 2 > &geometry, const Vector< T, 2 > &origin, const Vector< T, 2 > &u, BlockDataReductionMode mode=BlockDataReductionMode::Analytical)
 Constructor providing automatic lattice parametrization, only interpolating material 1.
 
bool operator() (T output[], const int input[]) override
 Returns the line integral in the following structure:
 
- Public Member Functions inherited from olb::SuperF2D< T, W >
SuperF2D< T, W > & operator- (SuperF2D< T, W > &rhs)
 
SuperF2D< T, W > & operator+ (SuperF2D< T, W > &rhs)
 
SuperF2D< T, W > & operator* (SuperF2D< T, W > &rhs)
 
SuperF2D< T, W > & operator/ (SuperF2D< T, W > &rhs)
 
SuperStructure< T, 2 > & getSuperStructure ()
 
int getBlockFSize () const
 
BlockF2D< W > & getBlockF (int iCloc)
 
bool operator() (W output[], const int input[]) override
 
- Public Member Functions inherited from olb::GenericF< T, S >
virtual ~GenericF ()=default
 
int getSourceDim () const
 read only access to member variable _m
 
int getTargetDim () const
 read only access to member variable _n
 
std::string & getName ()
 read and write access to name
 
std::string const & getName () const
 read only access to name
 
virtual bool operator() (T output[], const S input[])=0
 has to be implemented for 'every' derived class
 
bool operator() (T output[])
 wrapper that call the pure virtual operator() (T output[], const S input[]) from above
 
bool operator() (T output[], S input0)
 
bool operator() (T output[], S input0, S input1)
 
bool operator() (T output[], S input0, S input1, S input2)
 
bool operator() (T output[], S input0, S input1, S input2, S input3)
 

Protected Member Functions

bool isToBeIntegrated (const Vector< T, 2 > &physR, int iC)
 This is determined using the _integrationIndicatorF indicated subset of the 2d hyperplane reduced by _reductionF.
 
- Protected Member Functions inherited from olb::SuperF2D< T, W >
 SuperF2D (SuperStructure< T, 2 > &superStructure, int targetDim)
 
- Protected Member Functions inherited from olb::GenericF< T, S >
 GenericF (int targetDim, int sourceDim)
 

Protected Attributes

SuperGeometry< T, 2 > & _geometry
 
FunctorPtr< SuperF2D< T > > _f
 Functor to be integrated on the line.
 
FunctorPtr< SuperIndicatorF2D< T > > _integrationIndicatorF
 Indicator describing relevant discrete integration points.
 
FunctorPtr< IndicatorF1D< T > > _subplaneIndicatorF
 Indicator describing the relevant subset of the interpolated hyperplane.
 
BlockReduction2D1D< T > _reductionF
 Functor describing line to be interpolated and integrated.
 
Vector< T, 2 > _origin
 Origin vector as given by hyperplane definition, (0,0) in respect to the subplane indicator _subplaneIndicatorF.
 
Vector< T, 2 > _u
 Direction vector u as given by hyperplane definition, normalized to h.
 
Vector< T, 2 > _normal
 Orthogonal vector to _u.
 
std::vector< int > _rankLocalSubplane
 Subset of the discrete line points given by _reductionF as indicated by _integrationIndicatorF.
 
- Protected Attributes inherited from olb::SuperF2D< T, W >
SuperStructure< T, 2 > & _superStructure
 
std::vector< std::unique_ptr< BlockF2D< W > > > _blockF
 Super functors may consist of several BlockF2D<W> derived functors.
 

Additional Inherited Members

- Public Types inherited from olb::SuperF2D< T, W >
using identity_functor_type = SuperIdentity2D<T,W>
 
- Public Types inherited from olb::GenericF< T, S >
using targetType = T
 
using sourceType = S
 
- Public Attributes inherited from olb::GenericF< T, S >
std::shared_ptr< GenericF< T, S > > _ptrCalcC
 memory management, frees resouces (calcClass)
 

Detailed Description

template<typename T>
class olb::SuperPlaneIntegralF2D< T >

Surface integral of a subset of a interpolated hyperplane.

Definition at line 44 of file superPlaneIntegralF2D.h.

Constructor & Destructor Documentation

◆ SuperPlaneIntegralF2D() [1/5]

template<typename T >
olb::SuperPlaneIntegralF2D< T >::SuperPlaneIntegralF2D ( FunctorPtr< SuperF2D< T > > && f,
SuperGeometry< T, 2 > & geometry,
const HyperplaneLattice2D< T > & hyperplaneLattice,
FunctorPtr< SuperIndicatorF2D< T > > && integrationIndicator,
FunctorPtr< IndicatorF1D< T > > && subplaneIndicator,
BlockDataReductionMode mode = BlockDataReductionMode::Analytical )

Primary constructor.

All other constructors defer the actual construction to this constructor.

Parameters
f(non-)owning pointer or reference to SuperF2D<T>.
hyperplaneLatticeParametrization of the hyperplane lattice to be interpolated.
integrationIndicator(non-)owning pointer or reference to SuperIndicatorF2D<T>. Describes the set of lattice points relevant for integration.
subplaneIndicator(non-)owning pointer or reference to IndicatorF2D<T>. Describes the relevant subplane of the interpolated hyperplane.
modeDefines how the values of the discrete hyperplane are determined. i.e. if they are interpolated or read directly from lattice points. Note: BlockDataReductionMode::Analytical imposes restrictions on hyperplane definition and discretization. If you are not sure consider providing only a hyperplane defintion instead of both a definition and a discretization.

Definition at line 56 of file superPlaneIntegralF2D.hh.

63 : SuperF2D<T>(f->getSuperStructure(), 2 + f->getTargetDim()),
64 _geometry(geometry),
65 _f(std::move(f)),
66 _integrationIndicatorF(std::move(integrationIndicator)),
67 _subplaneIndicatorF(std::move(subplaneIndicator)),
69 hyperplaneLattice,
71 mode),
72 _origin(hyperplaneLattice.getHyperplane().origin),
73 _u(hyperplaneLattice.getVectorU()),
74 _normal(hyperplaneLattice.getHyperplane().normal)
75{
76 this->getName() = "SuperPlaneIntegralF2D";
77
79 _u = normalize(_u);
80
81 for ( const std::tuple<int,int>& pos : _reductionF.getRankLocalSubplane() ) {
82 const int& i = std::get<0>(pos);
83 const int& iC = std::get<1>(pos);
84 const Vector<T,2> physR = _reductionF.getPhysR(i);
85 if (isToBeIntegrated(physR, iC)) {
86 // check if interpolated hyperplane is to be restricted further
87 // e.g. using IndicatorCircle2D
88 if ( _subplaneIndicatorF ) {
89 // determine physical coordinates relative to original hyperplane origin
90 // [!] different from _reductionF._origin in the general case.
91 const Vector<T,2> physRelativeToOrigin = physR - _origin;
92 const T physOnHyperplane = physRelativeToOrigin * _u;
93
94 if ( _subplaneIndicatorF->operator()(&physOnHyperplane) ) {
95 _rankLocalSubplane.emplace_back(i);
96 }
97 }
98 else {
99 // plane is not restricted further
100 _rankLocalSubplane.emplace_back(i);
101 }
102 }
103 }
104}
std::string & getName()
read and write access to name
Definition genericF.hh:51
FunctorPtr< IndicatorF1D< T > > _subplaneIndicatorF
Indicator describing the relevant subset of the interpolated hyperplane.
BlockReduction2D1D< T > _reductionF
Functor describing line to be interpolated and integrated.
Vector< T, 2 > _normal
Orthogonal vector to _u.
std::vector< int > _rankLocalSubplane
Subset of the discrete line points given by _reductionF as indicated by _integrationIndicatorF.
bool isToBeIntegrated(const Vector< T, 2 > &physR, int iC)
This is determined using the _integrationIndicatorF indicated subset of the 2d hyperplane reduced by ...
FunctorPtr< SuperIndicatorF2D< T > > _integrationIndicatorF
Indicator describing relevant discrete integration points.
SuperGeometry< T, 2 > & _geometry
Vector< T, 2 > _u
Direction vector u as given by hyperplane definition, normalized to h.
FunctorPtr< SuperF2D< T > > _f
Functor to be integrated on the line.
Vector< T, 2 > _origin
Origin vector as given by hyperplane definition, (0,0) in respect to the subplane indicator _subplane...
constexpr Vector< T, D > normalize(const ScalarVector< T, D, IMPL > &a, T scale=T{1})
Definition vector.h:245
@ None
optimize for usage in e.g. SuperLatticeFlux3D, only rank-local data available

References olb::SuperPlaneIntegralF2D< T >::_normal, olb::SuperPlaneIntegralF2D< T >::_origin, olb::SuperPlaneIntegralF2D< T >::_rankLocalSubplane, olb::SuperPlaneIntegralF2D< T >::_reductionF, olb::SuperPlaneIntegralF2D< T >::_subplaneIndicatorF, olb::SuperPlaneIntegralF2D< T >::_u, olb::GenericF< T, S >::getName(), olb::SuperPlaneIntegralF2D< T >::isToBeIntegrated(), and olb::normalize().

+ Here is the call graph for this function:

◆ SuperPlaneIntegralF2D() [2/5]

template<typename T >
olb::SuperPlaneIntegralF2D< T >::SuperPlaneIntegralF2D ( FunctorPtr< SuperF2D< T > > && f,
SuperGeometry< T, 2 > & geometry,
const Hyperplane2D< T > & hyperplane,
FunctorPtr< SuperIndicatorF2D< T > > && integrationIndicator,
FunctorPtr< IndicatorF1D< T > > && subplaneIndicator,
BlockDataReductionMode mode = BlockDataReductionMode::Analytical )

Constructor providing automatic lattice generation.

Parameters
f(non-)owning pointer or reference to SuperF2D<T>.
hyperplaneParametrization of the hyperplane to be integrated. The lattice resolution is set to CuboidGeometry2D<T>::getMinDeltaR.
integrationIndicator(non-)owning pointer or reference to SuperIndicatorF2D<T>. Describes the set of lattice points relevant for integration.
subplaneIndicator(non-)owning pointer or reference to IndicatorF2D<T>. Describes the relevant subplane of the interpolated hyperplane.
modeDefines how the values of the discrete hyperplane are determined. i.e. if they are interpolated or read directly from lattice points.

Definition at line 107 of file superPlaneIntegralF2D.hh.

115 std::forward<decltype(f)>(f),
116 geometry,
117 HyperplaneLattice2D<T>(geometry.getCuboidGeometry(), hyperplane),
118 std::forward<decltype(integrationIndicator)>(integrationIndicator),
119 std::forward<decltype(subplaneIndicator)>(subplaneIndicator),
120 mode)
121{ }
SuperPlaneIntegralF2D(FunctorPtr< SuperF2D< T > > &&f, SuperGeometry< T, 2 > &geometry, const HyperplaneLattice2D< T > &hyperplaneLattice, FunctorPtr< SuperIndicatorF2D< T > > &&integrationIndicator, FunctorPtr< IndicatorF1D< T > > &&subplaneIndicator, BlockDataReductionMode mode=BlockDataReductionMode::Analytical)
Primary constructor.
CuboidGeometry< T, D > & getCuboidGeometry()
Read and write access to cuboid geometry.

◆ SuperPlaneIntegralF2D() [3/5]

template<typename T >
olb::SuperPlaneIntegralF2D< T >::SuperPlaneIntegralF2D ( FunctorPtr< SuperF2D< T > > && f,
SuperGeometry< T, 2 > & geometry,
const Hyperplane2D< T > & hyperplane,
FunctorPtr< SuperIndicatorF2D< T > > && integrationIndicator,
BlockDataReductionMode mode = BlockDataReductionMode::Analytical )

Constructor providing automatic lattice generation and omitting subplane restriction.

i.e. the intersection between geometry and hyperplane is integrated wherever _integrationIndicatorF allows.

Parameters
f(non-)owning pointer or reference to SuperF2D<T>.
hyperplaneParametrization of the hyperplane to be integrated. The lattice resolution is set to the cuboid geometry's minDeltaR.
integrationIndicator(non-)owning pointer or reference to SuperIndicatorF2D<T>. Describes the set of lattice points relevant for integration.
modeDefines how the values of the discrete hyperplane are determined. i.e. if they are interpolated or read directly from lattice points.

Definition at line 124 of file superPlaneIntegralF2D.hh.

131 std::forward<decltype(f)>(f),
132 geometry,
133 hyperplane,
134 std::forward<decltype(integrationIndicator)>(integrationIndicator),
135 nullptr,
136 mode)
137{ }

◆ SuperPlaneIntegralF2D() [4/5]

template<typename T >
olb::SuperPlaneIntegralF2D< T >::SuperPlaneIntegralF2D ( FunctorPtr< SuperF2D< T > > && f,
SuperGeometry< T, 2 > & geometry,
const Vector< T, 2 > & origin,
const Vector< T, 2 > & u,
std::vector< int > materials,
BlockDataReductionMode mode = BlockDataReductionMode::Analytical )

Constructor providing automatic lattice and material indicator instantiation.

Parameters
f(non-)owning pointer or reference to SuperF2D<T>.
originhyperplane origin origin
uhyperplane direction vector
materialsmaterial numbers relevant for hyperplane integration
modedefines how the values of the discrete hyperplane are determined

Definition at line 140 of file superPlaneIntegralF2D.hh.

147 std::forward<decltype(f)>(f),
148 geometry,
149 Hyperplane2D<T>().originAt(origin).parallelTo(u),
150 geometry.getMaterialIndicator(std::forward<decltype(materials)>(materials)),
151 mode)
152{ }
std::unique_ptr< SuperIndicatorF< T, D > > getMaterialIndicator(std::vector< int > &&materials)
Returns a material indicator using the given vector of materials.

◆ SuperPlaneIntegralF2D() [5/5]

template<typename T >
olb::SuperPlaneIntegralF2D< T >::SuperPlaneIntegralF2D ( FunctorPtr< SuperF2D< T > > && f,
SuperGeometry< T, 2 > & geometry,
const Vector< T, 2 > & origin,
const Vector< T, 2 > & u,
BlockDataReductionMode mode = BlockDataReductionMode::Analytical )

Constructor providing automatic lattice parametrization, only interpolating material 1.

Parameters
f(non-)owning pointer or reference to SuperF2D<T>.
originhyperplane origin
uhyperplane direction vector
modedefines how the values of the discrete hyperplane are determined

Definition at line 155 of file superPlaneIntegralF2D.hh.

161 std::forward<decltype(f)>(f),
162 geometry,
163 origin, u,
164 std::vector<int>(1,1),
165 mode)
166{ }

Member Function Documentation

◆ isToBeIntegrated()

template<typename T >
bool olb::SuperPlaneIntegralF2D< T >::isToBeIntegrated ( const Vector< T, 2 > & physR,
int iC )
protected

This is determined using the _integrationIndicatorF indicated subset of the 2d hyperplane reduced by _reductionF.

Returns
true iff the given physical position is to be integrated

Definition at line 36 of file superPlaneIntegralF2D.hh.

37{
38 Vector<int,3> latticeR;
39 //get nearest lattice point
40 if ( _geometry.getCuboidGeometry().getFloorLatticeR(physR, latticeR) ) {
41 const int& iX = latticeR[1];
42 const int& iY = latticeR[2];
43
44 // interpolation is possible iff all neighbours are within the indicated subset
45 return _integrationIndicatorF->operator()( iC, iX, iY )
46 && _integrationIndicatorF->operator()(iC, iX, iY+1)
47 && _integrationIndicatorF->operator()(iC, iX+1, iY )
48 && _integrationIndicatorF->operator()(iC, iX+1, iY+1);
49 }
50 else {
51 return false;
52 }
53}
+ Here is the caller graph for this function:

◆ operator()()

template<typename T >
bool olb::SuperPlaneIntegralF2D< T >::operator() ( T output[],
const int input[] )
override

Returns the line integral in the following structure:

output[0] = integral, e.g. flow[0] * h for 1-dimensional target sizes
output[1] = #voxels * h i.e. length of line
output[2..2+f.getTargetSize()] = flow

Note: output[0] contains the flux value if applicable

Parameters
inputirrelevant

Definition at line 170 of file superPlaneIntegralF2D.hh.

171{
173
174 _reductionF.update();
175
176 const int flowDim = _reductionF.getTargetDim();
177
178 std::vector<T> flow(flowDim,0.);
179
180 for ( int pos : _rankLocalSubplane ) {
181 T outputTmp[flowDim];
182 _reductionF(outputTmp, pos);
183
184 for ( int j = 0; j < flowDim; j++ ) {
185 flow[j] += outputTmp[j];
186 }
187 }
188
189 int vox = _rankLocalSubplane.size();
190
191#ifdef PARALLEL_MODE_MPI
192 for ( int j = 0; j < flowDim; j++ ) {
193 singleton::mpi().reduceAndBcast(flow[j], MPI_SUM);
194 }
195 singleton::mpi().reduceAndBcast(vox, MPI_SUM);
196#endif
197
198 const T h = _reductionF.getPhysSpacing();
199
200 switch ( flowDim ) {
201 case 1: {
202 output[0] = flow[0] * h;
203 break;
204 }
205 case 2: {
206 output[0] = (h * Vector<T,2>(flow)) * _normal;
207 break;
208 }
209 }
210
211 // area
212 output[1] = vox * h;
213 // write flow to output[2..]
214 std::copy_n(flow.cbegin(), flowDim, &output[2]);
215
216 return true;
217}
SuperStructure< T, 2 > & getSuperStructure()
virtual void communicate()
void reduceAndBcast(T &reductVal, MPI_Op op, int root=0, MPI_Comm comm=MPI_COMM_WORLD)
Reduction operation, followed by a broadcast.
MpiManager & mpi()

References olb::GenericF< T, S >::getTargetDim(), olb::singleton::mpi(), and olb::singleton::MpiManager::reduceAndBcast().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ _f

template<typename T >
FunctorPtr<SuperF2D<T> > olb::SuperPlaneIntegralF2D< T >::_f
protected

Functor to be integrated on the line.

Definition at line 49 of file superPlaneIntegralF2D.h.

◆ _geometry

template<typename T >
SuperGeometry<T,2>& olb::SuperPlaneIntegralF2D< T >::_geometry
protected

Definition at line 46 of file superPlaneIntegralF2D.h.

◆ _integrationIndicatorF

template<typename T >
FunctorPtr<SuperIndicatorF2D<T> > olb::SuperPlaneIntegralF2D< T >::_integrationIndicatorF
protected

Indicator describing relevant discrete integration points.

Definition at line 51 of file superPlaneIntegralF2D.h.

◆ _normal

template<typename T >
Vector<T,2> olb::SuperPlaneIntegralF2D< T >::_normal
protected

Orthogonal vector to _u.

Definition at line 68 of file superPlaneIntegralF2D.h.

◆ _origin

template<typename T >
Vector<T,2> olb::SuperPlaneIntegralF2D< T >::_origin
protected

Origin vector as given by hyperplane definition, (0,0) in respect to the subplane indicator _subplaneIndicatorF.

Note: The reduced plane _reductionF calculates its own origin based on _origin as its spans the maximum size possible given the direction vector, origin and geometry size.

Definition at line 64 of file superPlaneIntegralF2D.h.

◆ _rankLocalSubplane

template<typename T >
std::vector<int> olb::SuperPlaneIntegralF2D< T >::_rankLocalSubplane
protected

Subset of the discrete line points given by _reductionF as indicated by _integrationIndicatorF.

i.e. the points used to interpolate the hyperplane

Definition at line 72 of file superPlaneIntegralF2D.h.

◆ _reductionF

template<typename T >
BlockReduction2D1D<T> olb::SuperPlaneIntegralF2D< T >::_reductionF
protected

Functor describing line to be interpolated and integrated.

Definition at line 55 of file superPlaneIntegralF2D.h.

◆ _subplaneIndicatorF

template<typename T >
FunctorPtr<IndicatorF1D<T> > olb::SuperPlaneIntegralF2D< T >::_subplaneIndicatorF
protected

Indicator describing the relevant subset of the interpolated hyperplane.

Definition at line 53 of file superPlaneIntegralF2D.h.

◆ _u

template<typename T >
Vector<T,2> olb::SuperPlaneIntegralF2D< T >::_u
protected

Direction vector u as given by hyperplane definition, normalized to h.

Definition at line 66 of file superPlaneIntegralF2D.h.


The documentation for this class was generated from the following files: