|
[Sponsors] |
February 9, 2024, 12:11 |
Problems using Eqn.solve() on custom solver
|
#1 |
New Member
Erik Nijkamp
Join Date: Dec 2023
Posts: 5
Rep Power: 3 |
Hi all,
Long time lurker, but first time poster, but I hope that I do this right, and that someone can help me and that I can help someone in the future. In any case, I am trying to develop my own solver in OpenFOAM. This is a solver that should calculate the magnitude of induction heating due to a coiled wire with AC current. There are of course many equations to be solved, however the first one I need to solve is simply: curl(H) = J_Coil. J Coil is defined by the user, so this is a simple 1 unknown, 1 equation deal. I tried to solve it in OpenFOAM in the following way. First, define the needed varibles Code:
volVectorField HCoil ( IOobject ( "HCoil", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE ), mesh ); volVectorField JCoil ( IOobject ( "JCoil", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE ), mesh ); Code:
#include "fvCFD.H" int main(int argc, char *argv[]) { # include "setRootCase.H" # include "createTime.H" # include "createMesh.H" # include "createFields.H" # include "initConvergenceCheck.H" Info<< "\nStarting time loop\n" << endl; while (runTime.loop()) { Info<< "Time = " << runTime.timeName() << nl << endl; tmp<fvVectorMatrix> HCoilEqn ( fvc::curl(HCoil) - JCoil ); solve(HCoilEqn); #include "convergenceCheck.H" runTime.write(); } Info<< "End\n" << endl; return 0; Code:
MyEmFoam.C: In function ‘int main(int, char**)’: MyEmFoam.C:88:9: error: no matching function for call to ‘Foam::tmp<Foam::fvMatrix<Foam::Vector<double> > >::tmp(Foam::tmp<Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> >)’ 88 | ); | ^ In file included from /home/erik/foam/foam-extend-5.0/src/foam/lnInclude/tmp.H:140, from /home/erik/foam/foam-extend-5.0/src/foam/lnInclude/PtrListI.H:29, from /home/erik/foam/foam-extend-5.0/src/foam/lnInclude/PtrList.H:310, from /home/erik/foam/foam-extend-5.0/src/foam/lnInclude/List.C:30, from /home/erik/foam/foam-extend-5.0/src/foam/lnInclude/List.H:291, from /home/erik/foam/foam-extend-5.0/src/foam/lnInclude/labelList.H:36, from /home/erik/foam/foam-extend-5.0/src/foam/lnInclude/Pstream.H:43, from /home/erik/foam/foam-extend-5.0/src/foam/lnInclude/OPstream.H:35, from /home/erik/foam/foam-extend-5.0/src/foam/lnInclude/parRun.H:35, from /home/erik/foam/foam-extend-5.0/src/finiteVolume/lnInclude/fvCFD.H:4, from MyEmFoam.C:61: /home/erik/foam/foam-extend-5.0/src/foam/lnInclude/tmpI.H:74:8: note: candidate: ‘Foam::tmp<T>::tmp(const Foam::tmp<T>&, bool) [with T = Foam::fvMatrix<Foam::Vector<double> >]’ 74 | inline Foam::tmp<T>::tmp(const tmp<T>& t, bool allowTransfer) | ^~~~ /home/erik/foam/foam-extend-5.0/src/foam/lnInclude/tmpI.H:74:8: note: candidate expects 2 arguments, 1 provided /home/erik/foam/foam-extend-5.0/src/foam/lnInclude/tmpI.H:50:8: note: candidate: ‘Foam::tmp<T>::tmp(const Foam::tmp<T>&) [with T = Foam::fvMatrix<Foam::Vector<double> >]’ 50 | inline Foam::tmp<T>::tmp(const tmp<T>& t) | ^~~~ /home/erik/foam/foam-extend-5.0/src/foam/lnInclude/tmpI.H:50:40: note: no known conversion for argument 1 from ‘Foam::tmp<Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> >’ to ‘const Foam::tmp<Foam::fvMatrix<Foam::Vector<double> > >&’ 50 | inline Foam::tmp<T>::tmp(const tmp<T>& t) | ~~~~~~~~~~~~~~^ /home/erik/foam/foam-extend-5.0/src/foam/lnInclude/tmpI.H:41:8: note: candidate: ‘Foam::tmp<T>::tmp(const T&) [with T = Foam::fvMatrix<Foam::Vector<double> >]’ 41 | inline Foam::tmp<T>::tmp(const T& tRef) | ^~~~ /home/erik/foam/foam-extend-5.0/src/foam/lnInclude/tmpI.H:41:35: note: no known conversion for argument 1 from ‘Foam::tmp<Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> >’ to ‘const Foam::fvMatrix<Foam::Vector<double> >&’ 41 | inline Foam::tmp<T>::tmp(const T& tRef) | ~~~~~~~~~^~~~ /home/erik/foam/foam-extend-5.0/src/foam/lnInclude/tmpI.H:32:8: note: candidate: ‘Foam::tmp<T>::tmp(T*) [with T = Foam::fvMatrix<Foam::Vector<double> >]’ 32 | inline Foam::tmp<T>::tmp(T* tPtr) | ^~~~ /home/erik/foam/foam-extend-5.0/src/foam/lnInclude/tmpI.H:32:29: note: no known conversion for argument 1 from ‘Foam::tmp<Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> >’ to ‘Foam::fvMatrix<Foam::Vector<double> >*’ 32 | inline Foam::tmp<T>::tmp(T* tPtr) | ~~~^~~~ make: *** [MyEmFoam.dep:736: Make/linux64GccDPInt32Opt/MyEmFoam.o] Error 1 However, from other times that I have seen solve be used (in simpleFoam for example) it seems like they are doing something similar to me, so I am confused as to what is going wrong. At the risk of sounding stupid, I thought that fvVectorMatrix would make the matrix, so to me, I dont understand why it needs a matrix as an input, as I thought that it makes the matrix. Anyways, I hope that someone can help for. For the record, I am using foam-extend 5.0, as the old electromagnetic solver used fe. However, I can switch off of it if needed, but I think it should still work. |
|
February 12, 2024, 05:59 |
|
#2 |
New Member
Join Date: May 2019
Posts: 16
Rep Power: 7 |
Hi
I think the problem isn't the fvVectorMatrix itself, but that you're trying to construct it as a temporary object with that tmp<> wrapper. So if there is no specific reason for you to make that matrix temporary, I'd suggest to leave that tmp<> wrapper away. I hope that helps. Edit: I rethought this and no longer think that is the problem. Sorry about that |
|
February 12, 2024, 10:06 |
|
#3 |
New Member
Erik Nijkamp
Join Date: Dec 2023
Posts: 5
Rep Power: 3 |
Ah thanks anyways.
I did try something, I changed fvc::curl to fvm::lapcian, and then it did compile, however the mathematics are of course wrong. So perhaps this indicates that fvc::curl is not expecting as I expect it to. What do you think about this? Edit: I think I might have figured it out after looking at the fourm: problem with fvc:div TL;DR fvc::curl (and other fvc:: operators) are explicit, that is to say they don't output a matrix, only fvm:: operators do that. So I want to solve my problem, I will need to find out how to express my problem only using fvm:: operators. Back to the books I guess |
|
Tags |
matrix, solve, solver compilation error, types |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
CPUs vs GPUs for CFD? | hami11 | Hardware | 22 | July 23, 2024 16:59 |
Duplicate library entries when running a solver with custom library | francescomarra | OpenFOAM Programming & Development | 3 | May 17, 2022 09:37 |
Custom surface reaction solver with reactingParcelFoam doesn'd execute | MetEng | OpenFOAM Programming & Development | 0 | December 17, 2020 19:42 |
[ICEM] Problems with coedge curves and surfaces | tommymoose | ANSYS Meshing & Geometry | 6 | December 1, 2020 12:12 |
[OpenFOAM.org] Custom solver not running in parallel | syavash | OpenFOAM Installation | 12 | June 6, 2019 16:02 |