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

Add time dependent Source term

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

Like Tree2Likes
  • 2 Post By akidess

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 22, 2010, 04:54
Default Add time dependent Source term
  #1
New Member
 
Liberis
Join Date: Sep 2010
Posts: 9
Rep Power: 15
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 _ http://www.cfd-online.com/Forums/ope...gramming.html_ 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, 06:30
Default
  #2
Senior Member
 
akidess's Avatar
 
Anton Kidess
Join Date: May 2009
Location: Germany
Posts: 1,377
Rep Power: 29
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, 07:32
Default
  #3
New Member
 
Liberis
Join Date: Sep 2010
Posts: 9
Rep Power: 15
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, 07:58
Default
  #4
Senior Member
 
akidess's Avatar
 
Anton Kidess
Join Date: May 2009
Location: Germany
Posts: 1,377
Rep Power: 29
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, 08:31
Default
  #5
New Member
 
Liberis
Join Date: Sep 2010
Posts: 9
Rep Power: 15
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, 08:36
Default
  #6
New Member
 
Liberis
Join Date: Sep 2010
Posts: 9
Rep Power: 15
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, 08:41
Default
  #7
Senior Member
 
akidess's Avatar
 
Anton Kidess
Join Date: May 2009
Location: Germany
Posts: 1,377
Rep Power: 29
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, 08:47
Default
  #8
New Member
 
Liberis
Join Date: Sep 2010
Posts: 9
Rep Power: 15
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, 08:56
Default
  #9
Senior Member
 
akidess's Avatar
 
Anton Kidess
Join Date: May 2009
Location: Germany
Posts: 1,377
Rep Power: 29
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
Yage and reverseila like this.
akidess is offline   Reply With Quote

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

Old   September 22, 2010, 10:14
Default
  #11
Senior Member
 
Stefan Herbert
Join Date: Dec 2009
Location: Darmstadt, Germany
Posts: 129
Rep Power: 17
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, 04:03
Default
  #12
Senior Member
 
Pavan
Join Date: May 2009
Location: Melbourne
Posts: 101
Rep Power: 16
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, 08:30
Default
  #13
Senior Member
 
akidess's Avatar
 
Anton Kidess
Join Date: May 2009
Location: Germany
Posts: 1,377
Rep Power: 29
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, 10:12
Default
  #14
Senior Member
 
Pavan
Join Date: May 2009
Location: Melbourne
Posts: 101
Rep Power: 16
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 Search this Thread
Search this Thread:

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
wmake compiling new solver mksca OpenFOAM Programming & Development 14 June 22, 2018 07:29
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 18:51
Time Dependent Heat Sources Leon Mills Phoenics 1 July 3, 2001 06:22
UDFs for Scalar Eqn - Fluid/Solid HT Greg Perkins FLUENT 0 October 11, 2000 04:43


All times are GMT -4. The time now is 05:41.