CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

Need to integrate wallShearStress calculations into a solver

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 19, 2014, 10:49
Default Need to integrate wallShearStress calculations into a solver
  #1
Member
 
Fei Fan
Join Date: Jun 2013
Location: NanJing, China
Posts: 54
Rep Power: 12
Fanfei is on a distinguished road
Quote:
Originally Posted by lucchini View Post
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,

Last edited by wyldckat; September 13, 2014 at 05:59. Reason: Added [CODE][/CODE]
Fanfei is offline   Reply With Quote

Old   August 20, 2014, 05:38
Default
  #2
Member
 
Fei Fan
Join Date: Jun 2013
Location: NanJing, China
Posts: 54
Rep Power: 12
Fanfei is on a distinguished road
anyone can help me?
Fanfei is offline   Reply With Quote

Old   September 9, 2014, 08:32
Default
  #3
Member
 
Fei Fan
Join Date: Jun 2013
Location: NanJing, China
Posts: 54
Rep Power: 12
Fanfei is on a distinguished road
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

Last edited by wyldckat; September 13, 2014 at 06:01. Reason: Added [CODE][/CODE]
Fanfei is offline   Reply With Quote

Old   September 13, 2014, 06:09
Default
  #4
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,975
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
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
__________________
wyldckat is offline   Reply With Quote

Old   September 23, 2014, 05:54
Default
  #5
Member
 
Fei Fan
Join Date: Jun 2013
Location: NanJing, China
Posts: 54
Rep Power: 12
Fanfei is on a distinguished road
Quote:
Originally Posted by wyldckat View Post
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.
Fanfei is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unexplained Error during Solver Runs cfb CFX 6 November 9, 2012 15:42
Strange residuals of the Density Based Solver Pat84 FLUENT 0 October 22, 2012 15:59
Quarter Burner mesh with periosic condition SamCanuck FLUENT 2 August 31, 2011 11:34
Working directory via command line Luiz CFX 4 March 6, 2011 20:02
why the solver reject it? Anyone with experience? bearcat CFX 6 April 28, 2008 14:08


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