CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM Running, Solving & CFD

Add time dependent Source term

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   September 22, 2010, 03:54
Default Add time dependent Source term
  #1
New Member
 
Liberis
Join Date: Sep 2010
Posts: 9
Rep Power: 6
libe is on a distinguished road
Hello guys,
I am new in OpenFoam and I face several difficulties. I have followed the advice of Henrik for new openfoamers _ OpenFoam programming but still i cant find how to add in my model a new source term! I want to add the term
Source = A * cos(f * t)
I tried the following

while (runTime.loop())
{
Info<< "Time = " << runTime.timeName() << nl << endl;

Source = A* Foam::cos(f * runTime.time().value());

but nothing

and after the

At creatFields.H

volScalarField Source
(
"Source",
A* Foam::cos(f * runTime.time().value())
);

but nothing again...
I know its something very simple but I cant understand what I am missing!
Please help!
Thanks
libe is offline   Reply With Quote

Old   September 22, 2010, 05:30
Default
  #2
Senior Member
 
akidess's Avatar
 
Anton Kidess
Join Date: May 2009
Location: Delft, Netherlands
Posts: 919
Rep Power: 17
akidess will become famous soon enough
It sounds like you managed to create a source field, but you didn't include it in any equation.
akidess is offline   Reply With Quote

Old   September 22, 2010, 06:32
Default
  #3
New Member
 
Liberis
Join Date: Sep 2010
Posts: 9
Rep Power: 6
libe is on a distinguished road
Hello akidess for ur interest,
the system of equations that i try to solve is the following

while (runTime.loop())
{
Info<< "Time = " << runTime.timeName() << nl << endl;

// #include "readPISOControls.H"
// #include "CourantNo.H"

Source = A* Foam::cos(f * runTime.time().value());

tmp<fvVectorMatrix> EEqn
(
epsilon0*fvm::ddt(E)==fvc::curl(H)

);
// EEqn().relax();
EEqn().solve();


tmp<fvVectorMatrix> HEqn
(
mu*fvm::ddt(H)== -fvc::curl(E)+Source


);
// HEqn().relax();
HEqn().solve();

The transient form of Maxwell equations. When I put the Source term there are compiler's error. Is there any manual or something for general treatment of source terms?
libe is offline   Reply With Quote

Old   September 22, 2010, 06:58
Default
  #4
Senior Member
 
akidess's Avatar
 
Anton Kidess
Join Date: May 2009
Location: Delft, Netherlands
Posts: 919
Rep Power: 17
akidess will become famous soon enough
Quote:
Originally Posted by libe View Post
Code:
...
volScalarField Source = A* Foam::cos(f * runTime.time().value());
...
What errors do you get?
akidess is offline   Reply With Quote

Old   September 22, 2010, 07:31
Default
  #5
New Member
 
Liberis
Join Date: Sep 2010
Posts: 9
Rep Power: 6
libe is on a distinguished road
When I am using the lines that you mentioned at the creatField.H i take the following message

createFields.H:50: error: no matching function for call to ‘Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>::GeometricField(const char [7], Foam::doubleScalar)’
/home/stagiere/OpenFOAM/OpenFOAM-1.7.1/src/OpenFOAM/lnInclude/GeometricField.C:652: note: candidates are: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::IOobject&, const Foam::GeometricField<Type, PatchField, GeoMesh>&, const Foam::wordList&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh]
/home/stagiere/OpenFOAM/OpenFOAM-1.7.1/src/OpenFOAM/lnInclude/GeometricField.C:617: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::IOobject&, const Foam::GeometricField<Type, PatchField, GeoMesh>&, const Foam::word&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh]
/home/stagiere/OpenFOAM/OpenFOAM-1.7.1/src/OpenFOAM/lnInclude/GeometricField.C:587: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::word&, const Foam::tmp<Foam::GeometricField<Type, PatchField, GeoMesh> >&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh]
libe is offline   Reply With Quote

Old   September 22, 2010, 07:36
Default
  #6
New Member
 
Liberis
Join Date: Sep 2010
Posts: 9
Rep Power: 6
libe is on a distinguished road
when i am using the code u mentioned at the solver file myMycro.C I take:

myMicro.C:57: error: conversion from ‘Foam::doubleScalar’ to non-scalar type ‘Foam::volScalarField’ requested
/home/stagiere/OpenFOAM/OpenFOAM-1.7.1/src/finiteVolume/lnInclude/initContinuityErrs.H:37: warning: unused variable ‘cumulativeContErr’
make: *** [Make/linux64GccDPOpt/myMicro.o] Error 1
libe is offline   Reply With Quote

Old   September 22, 2010, 07:41
Default
  #7
Senior Member
 
akidess's Avatar
 
Anton Kidess
Join Date: May 2009
Location: Delft, Netherlands
Posts: 919
Rep Power: 17
akidess will become famous soon enough
How are A and f defined? Is f a scalar and A a volScalarField?
akidess is offline   Reply With Quote

Old   September 22, 2010, 07:47
Default
  #8
New Member
 
Liberis
Join Date: Sep 2010
Posts: 9
Rep Power: 6
libe is on a distinguished road
for the moment i remove A and f i let only the cos(t) in order to avoid athor problems.i just examine a very simple form
libe is offline   Reply With Quote

Old   September 22, 2010, 07:56
Default
  #9
Senior Member
 
akidess's Avatar
 
Anton Kidess
Join Date: May 2009
Location: Delft, Netherlands
Posts: 919
Rep Power: 17
akidess will become famous soon enough
It can't work like that for two reasons:
1. You are trying to assign a scalar value to a matrix. This is giving you the compiler error. Use
Code:
volScalarField Source
    (
        IOobject
        (
            "Source",
            runTime.timeName(),
            mesh,
            IOobject::NO_READ,
            IOobject::NO_WRITE
        ),
        mesh,
        dimensionedScalar("Source", dimensionSet(0,0,0,0,0,0,0), cos(runTime.time().value()))
    );
2. Using this will probably give you a run time error because the dimensions are not correct. Fill in the proper dimensions in the dimensionSet above and all should be well.

- Anton
akidess is offline   Reply With Quote

Old   September 22, 2010, 09:04
Default
  #10
New Member
 
Liberis
Join Date: Sep 2010
Posts: 9
Rep Power: 6
libe is on a distinguished road
Thank u Anton very much
libe is offline   Reply With Quote

Old   September 22, 2010, 09:14
Default
  #11
Senior Member
 
Stefan Herbert
Join Date: Dec 2009
Location: Darmstadt, Germany
Posts: 129
Rep Power: 8
herbert is on a distinguished road
Hi,

correct me if I'm wrong, but shouldn't Source be of type volVectorField? Just because it is a source term inside a vector equation.

Regards,
Stefan
herbert is offline   Reply With Quote

Old   September 23, 2010, 03:03
Default
  #12
Senior Member
 
Pavan
Join Date: May 2009
Location: Melbourne
Posts: 101
Rep Power: 8
rieuk is on a distinguished road
I was thinking the same thing (volVectorField). Also, could someone explain what the difference between runtime.value() and runtime.time().value() is?
rieuk is offline   Reply With Quote

Old   September 23, 2010, 07:30
Default
  #13
Senior Member
 
akidess's Avatar
 
Anton Kidess
Join Date: May 2009
Location: Delft, Netherlands
Posts: 919
Rep Power: 17
akidess will become famous soon enough
Stefan: Yes, I overlooked that this is a vector equation, so I guess the source should be a volVectorField.

Rieuk: If I remember correct former will give you a dimensionedScalar, while the latter expression will give you a raw number.
akidess is offline   Reply With Quote

Old   September 23, 2010, 09:12
Default
  #14
Senior Member
 
Pavan
Join Date: May 2009
Location: Melbourne
Posts: 101
Rep Power: 8
rieuk is on a distinguished road
Thanks Anton. I've been using runTime.value() all this time assuming it was dimensionless. However wmake gives no dimension errors when compiling...could this be giving me bad solutions?
rieuk is offline   Reply With Quote

Reply

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
wmake compiling new solver mksca OpenFOAM Programming & Development 13 August 18, 2014 22:26
time dependent source using DEFINE_SOURCE T81 Fluent UDF and Scheme Programming 5 February 28, 2011 18:23
DecomposePar links against liblamso0 with OpenMPI jens_klostermann OpenFOAM Bugs 11 June 28, 2007 17:51
Time Dependent Heat Sources Leon Mills Phoenics 1 July 3, 2001 05:22
UDFs for Scalar Eqn - Fluid/Solid HT Greg Perkins FLUENT 0 October 11, 2000 03:43


All times are GMT -4. The time now is 18:03.