CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM (https://www.cfd-online.com/Forums/openfoam/)
-   -   Coded boundary condition for dynamic mesh (https://www.cfd-online.com/Forums/openfoam/199790-coded-boundary-condition-dynamic-mesh.html)

delcmo March 15, 2018 08:33

Coded boundary condition for dynamic mesh
 
Hello,

I am trying to model a synthetic jet that is produced by a membrane vibrating in a cavity. The membrane is treated as a boundary condition that is a function of space and time as follows: sin(freq*time)*sin(pi*x) where freq is the frequency, time is time, and x is the spatial coordinates.

I started from the example located in '/opt/openfoam4/tutorials/incompressible/pimpleDyMFoam/movingCone'

One option I tried is to use the coded boundary condition class. I successfully implemented a parabolic inlet velocity boundary condition for velocity and temperature fields as a training exercise. I then tried the same approach for pointMotionUx but this variable is defined at vertices and not cell centers.

I was able to figure out functions to access time and vertices (I think) using Doxygen. The current version of the boundary implementation is the following:

Code:

            const polyMesh& mesh = this->internalField().mesh()();
            const Time& tt = mesh.time();
            const pointPatch& p = this->patch();

            operator==( sin(constant::mathematical::pi*10*t)*sin(10*p.localPoints() );

when openfoam compiles before running, I get the below error message:

/home/openfoam/run/piston/0/pointMotionUx.boundaryField.inlet: In member function 'virtual void Foam::testFixedValuePointPatchScalarField::updateC oeffs()':
/home/openfoam/run/piston/0/pointMotionUx.boundaryField.inlet:71:85: error: no matching function for call to 'sin(Foam::tmp<Foam::Field<Foam::Vector<double> > >)'

Any help would be appreciated.

Thanks,

Marco

alexeym March 17, 2018 02:41

Hi,

The error is quite clear: there is no sin function with vector argument, since p.localPoints() is a list of points, which are vectors. Use component method of Field class (https://cpp.openfoam.org/v5/classFoa...5fd130cb44a20e) to extract X (or whatever) component of point coordinate. Also, since you have tmp<Field<...>>, you need to use () operator to get to underlying Field object.


All times are GMT -4. The time now is 08:39.