Dear All,

Thanks everyone for your help.

Gion suggested a solution (I think his email did not go through on the server), 
which works fine in my problem.file.

const GravityVector &gravityAtPos(const GlobalPosition &pos) const
          {
                        if (pos[0] <  20)

                            { gravity_[0] = -100;  }
                        else
                            {  gravity_[0] = 100;    }

        return gravity_;
          }
with

mutable DimVector gravity_;

Best regards,
Felix

From: Dumux [mailto:dumux-boun...@listserv.uni-stuttgart.de] On Behalf Of 
georg.fut...@dlr.de
Sent: Tuesday, January 08, 2019 5:22 PM
To: dumux@listserv.uni-stuttgart.de
Subject: Re: [DuMuX] gravity dependency on global postion

Hi Timo,

Thanks for the correction ☺

Georg

Von: Dumux [mailto:dumux-boun...@listserv.uni-stuttgart.de] Im Auftrag von Timo 
Koch
Gesendet: Dienstag, 8. Januar 2019 09:22
An: DuMuX User Forum; Felix Feldmann
Betreff: Re: [DuMuX] gravity dependency on global postion


Hi Felix, hi Georg,



Georg's suggestion results in undefined behaviour because it's returning a 
reference to a temporary vector. You should also get a compiler warning for 
that.



@Felix on first sight there seems to be nothing wrong with your implementation, 
except that you should initialize your gravity_ variable (best practice).

Did you verify that your functions (the bit in preTimeStep and the gravityAtPos 
function)

is actually called? Maybe just put a console output in there or a break point 
for the debugger.



Timo


On 08.01.19 09:03, georg.fut...@dlr.de<mailto:georg.fut...@dlr.de> wrote:
Hi Felix,

You could try to run you problem with valgrind. Just type ‘valgrind 
./my_problem’ to do that. Then you might see where the error comes from. If the 
output does not give you an idea try to compile your problem with debug-opts 
and rerun it with valgrind.

Best regards
Georg

Von: Dumux [mailto:dumux-boun...@listserv.uni-stuttgart.de] Im Auftrag von 
Felix Feldmann
Gesendet: Dienstag, 8. Januar 2019 08:54
An: DuMuX User Forum
Betreff: Re: [DuMuX] gravity dependency on global postion

Dear Georg,

Thank you very much for the suggestion.

Unfortunately, I do get a segmentation fault (core dumped).
The error occurs independently from the used gravity values (I tried gravity 
values of 0, -9.81 or 100).

Best regards,
Felix



From: Dumux [mailto:dumux-boun...@listserv.uni-stuttgart.de] On Behalf Of 
georg.fut...@dlr.de<mailto:georg.fut...@dlr.de>
Sent: Monday, January 07, 2019 6:42 PM
To: dumux@listserv.uni-stuttgart.de<mailto:dumux@listserv.uni-stuttgart.de>
Subject: Re: [DuMuX] gravity dependency on global postion

Hi Felix,

You should try the following:

const GravityVector &gravityAtPos(const GlobalPosition &pos) const
{
// initialize a gravity vector with zeros
GravityVector gravity(0.0);

// modify the entry for the x (???) direction according to your needs
if (onLeftArea_( pos))
gravity[0]=100;
else // don’t use else if here so gravity[0] is always defined!
gravity[0]=-100;

return gravity;
}

Best regards
Georg

Von: Dumux [mailto:dumux-boun...@listserv.uni-stuttgart.de] Im Auftrag von 
Felix Feldmann
Gesendet: Montag, 7. Januar 2019 15:03
An: DuMuX User Forum
Betreff: Re: [DuMuX] gravity dependency on global postion

Hello Kilian & Timo,

Thanks for your quick reply.


1)      I initially added following line to my problem:

typedef Dune::FieldVector<Scalar, dimWorld> GravityVector;



2)      The gravity values are then defined inside the preTimeStep() function:

void preTimeStep()
{
if (GET_PARAM_FROM_GROUP(TypeTag, bool, Problem, EnableGravity))
                {
                                                                if 
(onLeftArea_(globalPos))

                                                           { gravity_=100; }

                                                     else if 
(onRightArea_(globalPos))
                                                                {  
gravity_=-100;  }
          }
}


3)      The gravity vector function is then added as suggested by Martin:


const GravityVector &gravityAtPos(const GlobalPosition &pos) const

                {  return gravity_;}


4)      Finally gravity_ is defined as a GravityVector:

  GravityVector gravity_;



Best regards,
Felix





From: Dumux [mailto:dumux-boun...@listserv.uni-stuttgart.de] On Behalf Of 
Kilian Weishaupt
Sent: Monday, January 07, 2019 5:15 PM
To: dumux@listserv.uni-stuttgart.de<mailto:dumux@listserv.uni-stuttgart.de>
Subject: Re: [DuMuX] gravity dependency on global postion

Hi Felix,

are you sure you correctly overloaded the gravityAtPos method in your problem? 
Maybe there is a typo and your code actually still uses the base class's method 
which returns a constant value.

Kilian
On 01/07/2019 11:58 AM, Timo Koch wrote:
Hi Felix,

how did you verify this? We would need some more information to see what the 
issue is. You get a position inside the gravity member function so if you use 
that to determine your gravity vector it should also use these different 
gravity vectors...

Timo

Am 07.01.2019 um 10:12 schrieb Felix Feldmann 
<felix.feldm...@ku.ac.ae<mailto:felix.feldm...@ku.ac.ae>>:
Dear Martin,

Thank you very much for your answer.

As suggested, I implemented the GravityVector method inside my problem file.

Although I defined different gravity values for each global position, the 
resulting gravity still appears to be just one constant value.

I am using DuMux 2.12.0

Kind regards,
Felix


From: Martin Schneider [mailto:martin.schnei...@iws.uni-stuttgart.de]
Sent: Wednesday, December 19, 2018 6:49 PM
To: DuMuX User Forum 
<dumux@listserv.uni-stuttgart.de<mailto:dumux@listserv.uni-stuttgart.de>>; 
Felix Feldmann <felix.feldm...@ku.ac.ae<mailto:felix.feldm...@ku.ac.ae>>
Subject: Re: [DuMuX] gravity dependency on global postion

Dear Felix,

you have to implement the following function
    const GravityVector &gravityAtPos(const GlobalPosition &pos) const
in your own problem file.
This overwrites the function from/dumux/porousmediumflow/problem.hh

I hope this helps.

Regards,
Martin

On 12/19/2018 03:43 PM, Felix Feldmann wrote:
Dear DuMux community,

Is there any method to define gravity 
dependency<https://www.dict.cc/englisch-deutsch/dependency.html> on the global 
position? Or in other words, is it possible to define a specific gravity value 
for each node?

Best regards,
Felix



_______________________________________________

Dumux mailing list

Dumux@listserv.uni-stuttgart.de<mailto:Dumux@listserv.uni-stuttgart.de>

https://listserv.uni-stuttgart.de/mailman/listinfo/dumux



--

M.Sc. Martin Schneider

University of Stuttgart

Institute for Modelling Hydraulic and Environmental Systems

Department of Hydromechanics and Modelling of Hydrosystems

Pfaffenwaldring 61

D-70569 Stuttgart

Tel: (+49) 0711/ 685-69159

Fax: (+49) 0711/ 685-60430

E-Mail: 
martin.schnei...@iws.uni-stuttgart.de<mailto:martin.schnei...@iws.uni-stuttgart.de>
_______________________________________________
Dumux mailing list
Dumux@listserv.uni-stuttgart.de<mailto:Dumux@listserv.uni-stuttgart.de>
https://listserv.uni-stuttgart.de/mailman/listinfo/dumux


_______________________________________________

Dumux mailing list

Dumux@listserv.uni-stuttgart.de<mailto:Dumux@listserv.uni-stuttgart.de>

https://listserv.uni-stuttgart.de/mailman/listinfo/dumux


--

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Kilian Weishaupt M.Sc.

Institut für Wasser- und Umweltsystemmodellierung (IWS)

Lehrstuhl für Hydromechanik und Hydrosystemmodellierung

Universität Stuttgart, Pfaffenwaldring 61, 70569 Stuttgart

Email: 
kilian.weisha...@iws.uni-stuttgart.de<mailto:kilian.weisha...@iws.uni-stuttgart.de>

Telefon: 0049 711 685-60461 ** fax: 0049-711-685-60430

http://www.hydrosys.uni-stuttgart.de

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


_______________________________________________

Dumux mailing list

Dumux@listserv.uni-stuttgart.de<mailto:Dumux@listserv.uni-stuttgart.de>

https://listserv.uni-stuttgart.de/mailman/listinfo/dumux

--

_______________________________________________________________



Timo Koch                              phone: +49 711 685 64676

IWS, Universität Stuttgart             fax:   +49 711 685 60430

Pfaffenwaldring 61        email: 
timo.k...@iws.uni-stuttgart.de<mailto:timo.k...@iws.uni-stuttgart.de>

D-70569 Stuttgart            url: 
www.hydrosys.uni-stuttgart.de<http://www.hydrosys.uni-stuttgart.de>

_______________________________________________________________
_______________________________________________
Dumux mailing list
Dumux@listserv.uni-stuttgart.de
https://listserv.uni-stuttgart.de/mailman/listinfo/dumux

Reply via email to