|
[Sponsors] |
September 22, 2010, 04:54 |
Add time dependent Source term
|
#1 |
New Member
Liberis
Join Date: Sep 2010
Posts: 9
Rep Power: 16 |
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 |
|
September 22, 2010, 06:30 |
|
#2 |
Senior Member
Anton Kidess
Join Date: May 2009
Location: Germany
Posts: 1,377
Rep Power: 30 |
It sounds like you managed to create a source field, but you didn't include it in any equation.
|
|
September 22, 2010, 07:32 |
|
#3 |
New Member
Liberis
Join Date: Sep 2010
Posts: 9
Rep Power: 16 |
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? |
|
September 22, 2010, 07:58 |
|
#4 |
Senior Member
Anton Kidess
Join Date: May 2009
Location: Germany
Posts: 1,377
Rep Power: 30 |
||
September 22, 2010, 08:31 |
|
#5 |
New Member
Liberis
Join Date: Sep 2010
Posts: 9
Rep Power: 16 |
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] |
|
September 22, 2010, 08:36 |
|
#6 |
New Member
Liberis
Join Date: Sep 2010
Posts: 9
Rep Power: 16 |
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 |
|
September 22, 2010, 08:41 |
|
#7 |
Senior Member
Anton Kidess
Join Date: May 2009
Location: Germany
Posts: 1,377
Rep Power: 30 |
How are A and f defined? Is f a scalar and A a volScalarField?
|
|
September 22, 2010, 08:47 |
|
#8 |
New Member
Liberis
Join Date: Sep 2010
Posts: 9
Rep Power: 16 |
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
|
|
September 22, 2010, 08:56 |
|
#9 |
Senior Member
Anton Kidess
Join Date: May 2009
Location: Germany
Posts: 1,377
Rep Power: 30 |
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())) ); - Anton |
|
September 22, 2010, 10:04 |
|
#10 |
New Member
Liberis
Join Date: Sep 2010
Posts: 9
Rep Power: 16 |
Thank u Anton very much
|
|
September 22, 2010, 10:14 |
|
#11 |
Senior Member
Stefan Herbert
Join Date: Dec 2009
Location: Darmstadt, Germany
Posts: 129
Rep Power: 18 |
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 |
|
September 23, 2010, 04:03 |
|
#12 |
Senior Member
Pavan
Join Date: May 2009
Location: Melbourne
Posts: 101
Rep Power: 17 |
I was thinking the same thing (volVectorField). Also, could someone explain what the difference between runtime.value() and runtime.time().value() is?
|
|
September 23, 2010, 08:30 |
|
#13 |
Senior Member
Anton Kidess
Join Date: May 2009
Location: Germany
Posts: 1,377
Rep Power: 30 |
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. |
|
September 23, 2010, 10:12 |
|
#14 |
Senior Member
Pavan
Join Date: May 2009
Location: Melbourne
Posts: 101
Rep Power: 17 |
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?
|
|
|
|
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 |