CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Need to integrate wallShearStress calculations into a solver (https://www.cfd-online.com/Forums/openfoam-programming-development/141668-need-integrate-wallshearstress-calculations-into-solver.html)

Fanfei August 19, 2014 10:49

Need to integrate wallShearStress calculations into a solver
 
Quote:

Originally Posted by lucchini (Post 207798)
Hi Susan,
you get the error because you try to assign to a scalar variable the product between a scalarField and a volScalarField.
You can get it working if you write:

volScalarField z = x*y*mag(U)

I hope it has been useful,
bye

Tommaso

Hi Tommaso:
I want to calculated volScalarField Shildes with volVectorField wallShearStress. The expression is Shildes=mag(wallShearStress)/(rho*g).

Code:

      volScalarField  rho
    (
      "rho",
      1000.0
    );

    volScalarField shileds
    (
      IOobject
      (
          "shileds",
            runTime.timeName(),
            mesh,
            IOobject::NO_READ,
            IOobject::NO_WRITE
        ),
        mesh,
      mag(wallShearStress)/(rho*g)     
      );

as compiled, some errors occured: could you give me some advices.
Code:

pimFoam.C:129:7: error: no matching function for call to ‘Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>::GeometricField(const char [4], double)’
pimFoam.C:129:7: note: candidates are:
In file included from /home/administrator/OpenFOAM/OpenFOAM-2.3.0/src/OpenFOAM/lnInclude/GeometricField.H:601:0,
                from /home/administrator/OpenFOAM/OpenFOAM-2.3.0/src/OpenFOAM/lnInclude/GeometricScalarField.H:38,
                from /home/administrator/OpenFOAM/OpenFOAM-2.3.0/src/OpenFOAM/lnInclude/GeometricFields.H:34,
                from /home/administrator/OpenFOAM/OpenFOAM-2.3.0/src/finiteVolume/lnInclude/volFields.H:37,
                from /home/administrator/OpenFOAM/OpenFOAM-2.3.0/src/finiteVolume/lnInclude/surfaceInterpolationScheme.C:30,
                from /home/administrator/OpenFOAM/OpenFOAM-2.3.0/src/finiteVolume/lnInclude/surfaceInterpolationScheme.H:234,


Fanfei August 20, 2014 05:38

anyone can help me?

Fanfei September 9, 2014 08:32

Hi, Bruno Santos: I wantto add the wallshearstress to pimpleFoam solver.the code is:
Code:

            while (pimple.correct())
            {
                #include "pEqn.H"
            }

            if (pimple.turbCorr())
            {
                turbulence->correct();
            }
        }

      Info<<"1  step"<<endl;
      autoPtr<incompressible::RASModel> model;
      Info<<"2 step"<<endl;
      const volSymmTensorField Reff(model->devReff());
      Info<<"3 step"<<endl;

 //  #include "createPhi.H"
  //    autoPtr<incompressible::RASModel> model;
  //  singlePhaseTransportModel laminarTransport(U, phi);
  //    Info<<"3 step"<<endl;
  //  autoPtr<incompressible::RASModel> model
  //  (
  //      incompressible::RASModel::New(U, phi, laminarTransport)
  //  );
 
    label patchWallID=mesh.boundaryMesh().findPatchID("bottomWall");

      volVectorField wallShearStress    //定义剪切应力
      (
          IOobject
            (
              "wallShearStress",
              runTime.timeName(),
              mesh,
              IOobject::NO_READ,
              IOobject::AUTO_WRITE
            ),
            mesh,
            dimensionedVector
            (
              "wallShearStress",
              sqr(dimLength)/sqr(dimTime),
              vector::zero
            )
      );
      { 
        wallShearStress.boundaryField()[patchWallID] =
        (
          -mesh.Sf().boundaryField()[patchWallID]
          /mesh.magSf().boundaryField()[patchWallID]
        ) & Reff.boundaryField()[patchWallID];
      }

when compiled, there is no problem. but as run a test, there're a problem
Code:

GAMG:  Solving for p, Initial residual = 0.0390428, Final residual = 6.86508e-08, No Iterations 25
time step continuity errors : sum local = 1.61558e-07, global = -3.77072e-08, cumulative = -2.71215e-05
smoothSolver:  Solving for epsilon, Initial residual = 0.187626, Final residual = 8.51315e-06, No Iterations 32
smoothSolver:  Solving for k, Initial residual = 1, Final residual = 8.18223e-06, No Iterations 45
1  step
2 step


--> FOAM FATAL ERROR:
object of type N4Foam14incompressible8RASModelE is not allocated

    From function Foam::autoPtr<T>::operator->()
    in file /home/administrator/OpenFOAM/OpenFOAM-2.3.0/src/OpenFOAM/lnInclude/autoPtrI.H at line 176.

FOAM aborting

#0  Foam::error::printStack(Foam::Ostream&) at ??:?
#1  Foam::error::abort() at ??:?
#2 
 at ??:?
#3 
 at ??:?
#4  __libc_start_main in "/lib/x86_64-linux-gnu/libc.so.6"
#5 
 at ??:?
Aborted (core dumped)

I think it's may be same parameters undefined, could you give me some advise? Thanks

wyldckat September 13, 2014 06:09

Hi Fei Fan,

I've moved your related posts above from the following threads:
I created this new thread in the programming sub-forum, since this is a programming related series of questions ;)


OK, regarding the latest post, what is happening is simple:
  1. The solver is telling you that you're trying to use a turbulence model that has not yet been allocated.
  2. This was because of you using this code:
    Code:

    autoPtr<incompressible::RASModel> model;
    const volSymmTensorField Reff(model->devReff());

    From a simple point of view, you only defined that the variable "model" is of type "autoPtr<incompressible::RASModel>". But you did not initialize the variable "model" with any values, therefore it's undefined, and in this case, not allocated.
  3. If you look at the code commented out a few lines below, you'll see how the turbulence model is being initialized, namely these lines are all related:
    Code:

    #include "createPhi.H"
    singlePhaseTransportModel laminarTransport(U, phi);
    autoPtr<incompressible::RASModel> model
    (
        incompressible::RASModel::New(U, phi, laminarTransport)
    );

  4. My advice is that you do a bit more careful studying and training in C++ as a programming language, before stepping directly into OpenFOAM's source code.
Best regards,
Bruno

Fanfei September 23, 2014 05:54

Quote:

Originally Posted by wyldckat (Post 510182)
Hi Fei Fan,

I've moved your related posts above from the following threads:
I created this new thread in the programming sub-forum, since this is a programming related series of questions ;)


OK, regarding the latest post, what is happening is simple:
  1. The solver is telling you that you're trying to use a turbulence model that has not yet been allocated.
  2. This was because of you using this code:
    Code:

    autoPtr<incompressible::RASModel> model;
    const volSymmTensorField Reff(model->devReff());

    From a simple point of view, you only defined that the variable "model" is of type "autoPtr<incompressible::RASModel>". But you did not initialize the variable "model" with any values, therefore it's undefined, and in this case, not allocated.
  3. If you look at the code commented out a few lines below, you'll see how the turbulence model is being initialized, namely these lines are all related:
    Code:

    #include "createPhi.H"
    singlePhaseTransportModel laminarTransport(U, phi);
    autoPtr<incompressible::RASModel> model
    (
        incompressible::RASModel::New(U, phi, laminarTransport)
    );

  4. My advice is that you do a bit more careful studying and training in C++ as a programming language, before stepping directly into OpenFOAM's source code.
Best regards,
Bruno

Thanks Bruno:
You are right, I have solved it. regards.


All times are GMT -4. The time now is 06:40.