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

coordinate depending source term

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 9, 2009, 14:55
Default coordinate depending source term
  #1
Member
 
Jagmohan Meena
Join Date: May 2009
Posts: 30
Rep Power: 17
jmmeena is on a distinguished road
Dear Sir/Madam,

I am doing a heat transfer problem with source term. Source term itself depends on the x,y,z, coordinates. I have tried following :

Teqn:

{
fvScalarMatrix TEqn
(
(rho)*(Cp)*fvm::ddt(T)
+ fvm::div(phi, T)
- (rho)*(Cp)*fvm::laplacian(DT, T)
==
Q
);

TEqn.relax();

eqnResidual = TEqn.solve().initialResidual();
maxResidual = max(eqnResidual, maxResidual);

}


Q is source term which is defined as:

Info<< "Reading sourceProperties\n" << endl;

IOdictionary sourceProperties
(
IOobject
(
"sourceProperties",
runTime.constant(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
);

dimensionedScalar Acos
(
sourceProperties.lookup("Acos")
);

dimensionedScalar Rcos
(
sourceProperties.lookup("Rcos")
);

dimensionedScalar Zcos
(
sourceProperties.lookup("Zcos")
);

dimensionedScalar Q("Q", Acos*cos(0.5*3.14*(sqrt((x[0]*x[0])+(x[1]*x[1])))/Rcos)*cos(0.5*3.14*x[2]/Zcos));

if (Q < 0.)
{
Q = 0.0;
}



Error:
readSourceProperties.H: In function ‘int main(int, char**)’:
readSourceProperties.H:30: erreur: ‘x’ was not declared in this scope
readSourceProperties.H:32: erreur: no match for ‘operator<’ in ‘Q < 0.0’
make: *** [Make/linux64GccDPOpt/sourceBuoyantSimpleFoam.o] Erreur 1


I thought to use x[0] for x, x[1] for y and x[2] for z ! but OpenFOAM reports error in this. Hence my question is: How to input coordinates for Q so that it OpenFOAM will understand it ?

thankyou in advance !!

regards,
JM
jmmeena is offline   Reply With Quote

Old   July 12, 2009, 14:44
Default
  #2
Senior Member
 
Henrik Rusche
Join Date: Mar 2009
Location: Wernigerode, Sachsen-Anhalt, Germany
Posts: 281
Rep Power: 18
henrik is on a distinguished road
Dear jmmeena,

1) Use mesh.C().x() for the x-coordinate

2) Your coordinate dependant source should be a volScalarField

3) Use max-function to bound Q @ zero

Henrik
henrik is offline   Reply With Quote

Old   July 15, 2009, 05:16
Default
  #3
Senior Member
 
isabel
Join Date: Apr 2009
Location: Spain
Posts: 171
Rep Power: 17
isabel is on a distinguished road
Thank you very much, Henrik.
I have wrotten these lines in my code:


volScalarField x = mesh.C().x();
volScalarField y = mesh.C().y();


and I have this error in these lines (line 89 and line 90):


isabel@isabel-desktop:~/OpenFOAM/isabel-1.5/applications/solvers/multiphase/interFoamModificado$ wmake
SOURCE=interFoamModificado.C ; g++ -m32 -Dlinux -DDP -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wold-style-cast -O3 -DNoRepository -ftemplate-depth-40 -I/home/isabel/OpenFOAM/OpenFOAM-1.5/src/transportModels -I/home/isabel/OpenFOAM/OpenFOAM-1.5/src/transportModels/incompressible/lnInclude -I/home/isabel/OpenFOAM/OpenFOAM-1.5/src/transportModels/interfaceProperties/lnInclude -I/home/isabel/OpenFOAM/OpenFOAM-1.5/src/finiteVolume/lnInclude -IlnInclude -I. -I/home/isabel/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude -I/home/isabel/OpenFOAM/OpenFOAM-1.5/src/OSspecific/Unix/lnInclude -fPIC -pthread -c $SOURCE -o Make/linuxGccDPOpt/interFoamModificado.o
In file included from interFoamModificado.C:84:
pEqn.H: In function ‘int main(int, char**)’:
pEqn.H:89: error: ‘const struct Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh>’ has no member named ‘x’
pEqn.H:90: error: ‘const struct Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh>’ has no member named ‘y’
/home/isabel/OpenFOAM/OpenFOAM-1.5/src/finiteVolume/lnInclude/readPISOControls.H:3: warning: unused variable ‘nCorr’
make: *** [Make/linuxGccDPOpt/interFoamModificado.o] Error 1
isabel@isabel-desktop:~/OpenFOAM/isabel-1.5/applications/solvers/multiphase/interFoamModificado$
isabel is offline   Reply With Quote

Old   July 15, 2009, 05:37
Default
  #4
Senior Member
 
Henrik Rusche
Join Date: Mar 2009
Location: Wernigerode, Sachsen-Anhalt, Germany
Posts: 281
Rep Power: 18
henrik is on a distinguished road
Dear Isabel, dear jmmeena,

stupid me ...

vector v;
Info << v.x(); // OK

volVectorField vf;
Info << vf.component(vector::X); // OK

Henrik
henrik is offline   Reply With Quote

Old   July 15, 2009, 05:55
Default
  #5
Senior Member
 
isabel
Join Date: Apr 2009
Location: Spain
Posts: 171
Rep Power: 17
isabel is on a distinguished road
Thank you very much, Henrik, but with these lines:


vector v;
Info << v.x();

volVectorField vf;
Info << vf.component(vector::X);


I have this error (line 90 is “volVectorField vf;”) :


isabel@isabel-desktop:~/OpenFOAM/isabel-1.5/applications/solvers/multiphase/interFoamModificado$ wmake
Making dependency list for source file interFoamModificado.C
SOURCE=interFoamModificado.C ; g++ -m32 -Dlinux -DDP -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wold-style-cast -O3 -DNoRepository -ftemplate-depth-40 -I/home/isabel/OpenFOAM/OpenFOAM-1.5/src/transportModels -I/home/isabel/OpenFOAM/OpenFOAM-1.5/src/transportModels/incompressible/lnInclude -I/home/isabel/OpenFOAM/OpenFOAM-1.5/src/transportModels/interfaceProperties/lnInclude -I/home/isabel/OpenFOAM/OpenFOAM-1.5/src/finiteVolume/lnInclude -IlnInclude -I. -I/home/isabel/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude -I/home/isabel/OpenFOAM/OpenFOAM-1.5/src/OSspecific/Unix/lnInclude -fPIC -pthread -c $SOURCE -o Make/linuxGccDPOpt/interFoamModificado.o
In file included from interFoamModificado.C:84:
pEqn.H: In function ‘int main(int, char**)’:
pEqn.H:90: error: no matching function for call to ‘Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh>::GeometricField()’
/home/isabel/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/GeometricField.C:611: note: candidates are: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::IOobject&, const Foam::GeometricField<Type, PatchField, GeoMesh>&, const Foam::wordList&) [with Type = Foam::Vector<double>, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh]
/home/isabel/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/GeometricField.C:576: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::IOobject&, const Foam::GeometricField<Type, PatchField, GeoMesh>&, const Foam::word&) [with Type = Foam::Vector<double>, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh]
/home/isabel/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/GeometricField.C:545: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::word&, const Foam::tmp<Foam::GeometricField<Type, PatchField, GeoMesh> >&) [with Type = Foam::Vector<double>, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh]
/home/isabel/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/GeometricField.C:512: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::word&, const Foam::GeometricField<Type, PatchField, GeoMesh>&) [with Type = Foam::Vector<double>, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh]
/home/isabel/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/GeometricField.C:480: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::IOobject&, const Foam::GeometricField<Type, PatchField, GeoMesh>&) [with Type = Foam::Vector<double>, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh]
/home/isabel/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/GeometricField.C:448: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::tmp<Foam::GeometricField<Type, PatchField, GeoMesh> >&) [with Type = Foam::Vector<double>, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh]
/home/isabel/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/GeometricField.C:416: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::GeometricField<Type, PatchField, GeoMesh>&) [with Type = Foam::Vector<double>, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh]
/home/isabel/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/GeometricField.C:378: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::IOobject&, const typename GeoMesh::Mesh&, Foam::Istream&) [with Type = Foam::Vector<double>, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh]
/home/isabel/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/GeometricField.C:337: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::IOobject&, const typename GeoMesh::Mesh&) [with Type = Foam::Vector<double>, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh]
/home/isabel/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/GeometricField.C:313: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::IOobject&, const typename GeoMesh::Mesh&, const Foam::dimensionSet&, const Foam::Field<Type>&, const Foam::PtrList<PatchField<Type> >&) [with Type = Foam::Vector<double>, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh]
/home/isabel/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/GeometricField.C:283: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::IOobject&, const typename GeoMesh::Mesh&, const Foam::dimensioned<Type>&, const Foam::wordList&) [with Type = Foam::Vector<double>, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh]
/home/isabel/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/GeometricField.C:254: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::IOobject&, const typename GeoMesh::Mesh&, const Foam::dimensioned<Type>&, const Foam::word&) [with Type = Foam::Vector<double>, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh]
/home/isabel/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/GeometricField.C:227: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::IOobject&, const typename GeoMesh::Mesh&, const Foam::dimensionSet&, const Foam::wordList&) [with Type = Foam::Vector<double>, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh]
/home/isabel/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude/GeometricField.C:197: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::IOobject&, const typename GeoMesh::Mesh&, const Foam::dimensionSet&, const Foam::word&) [with Type = Foam::Vector<double>, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh]
/home/isabel/OpenFOAM/OpenFOAM-1.5/src/finiteVolume/lnInclude/readPISOControls.H:3: warning: unused variable ‘nCorr’
make: *** [Make/linuxGccDPOpt/interFoamModificado.o] Error 1
isabel@isabel-desktop:~/OpenFOAM/isabel-1.5/applications/solvers/multiphase/interFoamModificado$
isabel is offline   Reply With Quote

Old   July 15, 2009, 06:06
Default
  #6
Senior Member
 
Henrik Rusche
Join Date: Mar 2009
Location: Wernigerode, Sachsen-Anhalt, Germany
Posts: 281
Rep Power: 18
henrik is on a distinguished road
Dear Isabel,

Quote:
class xyz;
was meant as a forward declaration and only actually works if the class has a null constructor and volVectorField does not. I just tried to say: "Given a volVectorField, do something like this".

Okay, you want to try:

Quote:
volScalarField x = mesh.C().component(vector::X);
volScalarField y = mesh.C().component(vector::Y);
Henrik
henrik is offline   Reply With Quote

Old   July 15, 2009, 06:18
Default
  #7
Senior Member
 
isabel
Join Date: Apr 2009
Location: Spain
Posts: 171
Rep Power: 17
isabel is on a distinguished road
Thank you very much, Henrik.
Now it works.
isabel 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
momentum source term zwdi FLUENT 14 June 27, 2017 16:40
DxFoam reader update hjasak OpenFOAM Post-Processing 69 April 24, 2008 02:24
DecomposePar links against liblamso0 with OpenMPI jens_klostermann OpenFOAM Bugs 11 June 28, 2007 18:51
UDFs for Scalar Eqn - Fluid/Solid HT Greg Perkins FLUENT 0 October 14, 2000 00:03
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 14:33.