Add time dependent Source term
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 |
It sounds like you managed to create a source field, but you didn't include it in any equation.
|
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? |
Quote:
|
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] |
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 |
How are A and f defined? Is f a scalar and A a volScalarField?
|
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
|
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 - Anton |
Thank u Anton very much :)
|
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 |
I was thinking the same thing (volVectorField). Also, could someone explain what the difference between runtime.value() and runtime.time().value() is?
|
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. |
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?
|
All times are GMT -4. The time now is 09:44. |