# Is it possible to setup a multiscalarfield with vicinity of 2?

Hi, everyone
I’m trying to calculate the local curvature in palabos based on the BBS model which needs to get the solid fraction of the neighboring nodes with the vicinity of 2. I do not know whether it is possible to setup a multiscalarfield of vicinity 2.

Thanks

Hi,

There exist several approaches. The simplest one is to use the function

[code=“cpp”]
template
std::auto_ptr<MultiScalarField3D > generateMultiScalarField (
Box3D boundingBox, T iniVal, plint envelopeWidth );

``````

defined in

``````

multiBlock/multiBlockGenerator3D.h

``````

You can for example create the 100x100x100 MultiScalarField "a" with vicinity of 2 as follows:

[code="cpp"]
MultiScalarField3D<double>* a = generateMultiScalarField(Box3D(0,99, 0,99, 0,99), 0., 2);

``````

There’s a minor inconvenience: “a” is a pointer and is then a bit more clumsy to handle than a static variable, but all in all, this remains the most convenient approach.

Cheers,
Jonas

Hi, jonas
I tried your suggestion and used:
MultiScalarField2D * solidfraction_dis = generateMultiScalarField (domain, 0., 1);

But the I got the error:

cannot convert ‘std::auto_ptr<plb::MultiScalarField2D >’ to ‘plb::MultiScalarField2D*’ in initialization

How can I fix this error?

Best,
suning

Right, there is a misprint in my post. The right syntax is

[code=“cpp”]
std::auto_ptr<MultiScalarField2D > solidfraction_dis = generateMultiScalarField (domain, 0., 1);

``````

solidfraction_dis is an "auto-pointer", which has the same syntax as a normal pointer, but is automatically de-allocated when the program gets out of the current scope.

Cheers,
Jonas``````

Hi,
I set up the scalar field successfully by using “std::auto_ptr<MultiScalarField2D >”. Thanks a lot.
But now, new problem comes up:
If I want to use the BoxProcessingFunctional2D to define a process for the scalar field, I need firstly define an argument to include all the involved data field, for example:
vector <MultiBlock2D*> get_curvature_arg;
get_curvature_arg.push_back (phase);
get_curvature_arg.push_back (curvature_dis);
get_curvature_arg.push_back (solidfraction_dis);

and then we can use
applyProcessingFunctional (new get_curvature (nx, ny), phase->getBoundingBox (), get_curvature_arg);
to carry out the calculation in the data field.

But the when I compile for this code, I get the error:
error: no matching function for call to ‘std::vector<plb::MultiBlock2D*, std::allocatorplb::MultiBlock2D* >::push_back(std::auto_ptr<plb::MultiScalarField2D >&)’
note: candidates are: void std::vector<_Tp, _Alloc>::push_back(const _Tp&) [with _Tp = plb::MultiBlock2D*, _Alloc = std::allocatorplb::MultiBlock2D*

It seems that the “std::auto_ptr<MultiScalarField2D >” will conflict with the " MultiScalarField3D* " type.

Thanks a lot!

Hi,

Write for example

[code=“cpp”]
phase.get()

``````

to access the raw pointer.

Cheers,
Jonas``````