|
[Sponsors] |
September 18, 2013, 12:15 |
codedFixedValue boundaries in parallel
|
#1 |
Member
Join Date: Sep 2012
Posts: 51
Rep Power: 14 |
Hello,
I'm using the codedFixedValue to set the pressure on the outlet on my case (flowRate at the inlet, pressure on the outlets). I used the flowRate on the outlets to set the pressure. When the run is sequential, everything works fine but in parallel, the pressure isn't applied correctly. My codeDict: Code:
//reading the pressure on the considered patch const volScalarField& p = db().lookupObject<volScalarField>("p"); const fvPatchField<scalar>& pip = patch().patchField<volScalarField, scalar>(p); //reading the flowRate on the considered patch const surfaceScalarField& phi = db().lookupObject<surfaceScalarField>("phi"); const fvsPatchField<scalar>& phip = patch().patchField<surfaceScalarField, scalar>(phi); int k=0; dimensionedScalar h("h",dimless, tstep.value()); dimensionedScalar pp("pp",dimless, average(pip)); //average pressure on the patch dimensionedScalar res("res",dimless,1E6); dimensionedScalar p0("p0",dimless, 1E6); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // pp += h * sum(phip); //test (*this)==(pp.value()); #}; Code:
--> FOAM Warning : From function average(const UList<Type>&) in file /home/apps/Logiciels/OpenFOAM/OpenFOAM-2.2.x/src/OpenFOAM/lnInclude/FieldFunctions.C at line 467 empty field, returning zero I guess I'm reading and writing the pressure and flowRate correctly but I don't really know what to do. edit : I think the problem is only the access of the data on the processor patch and not the whole BC ; how can I get these data ? If someone is able to help, thank you a lot. Florian Last edited by Hiroshiman; September 18, 2013 at 15:37. |
|
September 19, 2013, 05:47 |
|
#2 |
Senior Member
Joachim Herb
Join Date: Sep 2010
Posts: 650
Rep Power: 22 |
I think you have to use the OpenFOAM reduce functions to collect the data of all processors. These examples should help:
http://www.cfd-online.com/Forums/ope...tml#post429245 https://github.com/OpenFOAM/OpenFOAM...patchAverage.C |
|
September 19, 2013, 14:45 |
|
#3 |
Member
Join Date: Sep 2012
Posts: 51
Rep Power: 14 |
Thank you for the answer.
Actually, I'm a bit lost : I'm using the codedFixedValue BC and the structure of the code is quite different from what I see in the "real" BCs codes. For example, to get the patch area, I do : Code:
dimensionedScalar area("area",dimless, gSum(patch().magSf())); I tried to assign on cpu for each outlets but it simply crashes... |
|
September 19, 2013, 20:58 |
|
#4 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request |
||
September 19, 2013, 21:52 |
|
#5 |
Member
Join Date: Sep 2012
Posts: 51
Rep Power: 14 |
Ahem, I totally missed that obviously... Thank you for noticing, I'll try with the global sum and see how it behaves.
---------- edit Thank you very much, my results are identical between sequential and parallel runs. Best regards, Florian Last edited by Hiroshiman; September 20, 2013 at 11:21. |
|
October 5, 2016, 12:00 |
|
#6 |
New Member
Sachin
Join Date: Sep 2016
Location: Poitiers,France
Posts: 17
Rep Power: 10 |
I am using codedFixedValue bc for implementing ΔV=0 ;where V=x2+y2+z2
my boundarycondition at 0/phi is: inlet { type codedFixedValue; value uniform 0; redirectType velocitySquareInlet; code #{ const fvPatch& boundaryPatch = patch(); const vectorField& Cf = boundaryPatch.Cf(); scalarField& field = *this; forAll(Cf, faceI) { ( (Cf[faceI].x()=0) && (Cf[faceI].y()=0) && (Cf[faceI].z()=0) ) { field[faceI] = ((Cf[faceI].x()*Cf[faceI].x()) +(Cf[faceI].y()*Cf[faceI].y()) +(Cf[faceI].z()*Cf[faceI].z())); } } #}; and I will have following error at terminal Using dynamicCode for patch inlet on field phi at line 25 in "/home/sachin/OpenFOAM/Conduction/charge-20/0/phi.boundaryField.inlet" Creating new library in "dynamicCode/velocitySquareInlet/platforms/linux64GccDPInt32Opt/lib/libvelocitySquareInlet_f5eecc7ba736b15b9d60f3aa108 fc0cf20d513de.so" Invoking "wmake -s libso /home/sachin/OpenFOAM/Conduction/charge-20/dynamicCode/velocitySquareInlet" wmakeLnInclude: linking include files to ./lnInclude Making dependency list for source file fixedValueFvPatchFieldTemplate.C /home/sachin/OpenFOAM/Conduction/charge-20/0/phi.boundaryField.inlet: In member function virtual void Foam::velocitySquareInletFixedValueFvPatchScalarFi eld::updateCoeffs(): /home/sachin/OpenFOAM/Conduction/charge-20/0/phi.boundaryField.inlet:39:35: error: assignment of read-only location (&(& Cf)->Foam::Field<Foam::Vector<double> >::<anonymous>.Foam::List<Foam::Vector<double> >::<anonymous>.Foam::UList<T>erator[]<Foam::Vector<double> >(faceI))->Foam::Vector<Cmpt>::x<double>() /home/sachin/OpenFOAM/Conduction/charge-20/0/phi.boundaryField.inlet:40:35: error: assignment of read-only location (&(& Cf)->Foam::Field<Foam::Vector<double> >::<anonymous>.Foam::List<Foam::Vector<double> >::<anonymous>.Foam::UList<T>erator[]<Foam::Vector<double> >(faceI))->Foam::Vector<Cmpt>::y<double>() /home/sachin/OpenFOAM/Conduction/charge-20/0/phi.boundaryField.inlet:41:35: error: assignment of read-only location (&(& Cf)->Foam::Field<Foam::Vector<double> >::<anonymous>.Foam::List<Foam::Vector<double> >::<anonymous>.Foam::UList<T>erator[]<Foam::Vector<double> >(faceI))->Foam::Vector<Cmpt>::z<double>() /home/sachin/OpenFOAM/Conduction/charge-20/0/phi.boundaryField.inlet:43:17: error: expected ; before { token /home/sachin/OpenFOAM/Conduction/charge-20/0/phi.boundaryField.inlet:34:26: warning: unused variable field [-Wunused-variable] /opt/openfoam4/wmake/rules/General/transform:8: recipe for target 'Make/linux64GccDPInt32Opt/fixedValueFvPatchFieldTemplate.o' failed make: *** [Make/linux64GccDPInt32Opt/fixedValueFvPatchFieldTemplate.o] Error 1 --> FOAM FATAL IO ERROR: Failed wmake "dynamicCode/velocitySquareInlet/platforms/linux64GccDPInt32Opt/lib/libvelocitySquareInlet_f5eecc7ba736b15b9d60f3aa108 fc0cf20d513de.so" file: /home/sachin/OpenFOAM/Conduction/charge-20/0/phi.boundaryField.inlet from line 25 to line 30. From function void Foam::codedBase::createLibrary(Foam::dynamicCode&, const Foam::dynamicCodeContext&) const in file db/dynamicLibrary/codedBase/codedBase.C at line 206. FOAM exiting Does anyone know the solution? Thanks in advance!!!!! |
|
October 6, 2016, 10:34 |
|
#7 |
New Member
Sachin
Join Date: Sep 2016
Location: Poitiers,France
Posts: 17
Rep Power: 10 |
solve the problem....
inlet { type codedFixedValue; value uniform 0; redirectType velocitySquareInlet; code #{ const fvPatch& boundaryPatch = patch(); const vectorField& Cf = boundaryPatch.Cf(); scalarField& field = *this; forAll(Cf, faceI) { { field[faceI] = ((Cf[faceI].x()*Cf[faceI].x()) +(Cf[faceI].y()*Cf[faceI].y()) +(Cf[faceI].z()*Cf[faceI].z())); } } #}; solve it!!!! |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Parallel refineMesh with Cyclic Boundaries | mchurchf | OpenFOAM | 8 | December 22, 2018 12:11 |
simpleFoam in parallel issue | plucas | OpenFOAM Running, Solving & CFD | 3 | July 17, 2013 12:30 |
parallel Grief: BoundaryFields ok in single CPU but NOT in Parallel | JR22 | OpenFOAM Running, Solving & CFD | 2 | April 19, 2013 17:49 |
dynamic mesh interDyMFoam parallel run and processor boundaries | lukasfischer | OpenFOAM Running, Solving & CFD | 0 | August 12, 2009 07:36 |
Parallel Computing Classes at San Diego Supercomputer Center Jan. 20-22 | Amitava Majumdar | Main CFD Forum | 0 | January 5, 1999 13:00 |