So far I was using OGS for the analysis of a pile in drained conditions, but now I want to do the same analysis under undrained conditions and I want to know exactly how can I achieve undrained conditions in OGS.
Should I defined my initial stress field as total stresses?
How can I apply the initial ground water table of the soil? Should I apply it as a horizontal boundary condition equal to gamma_w*z?
I would really appreciate if someone could point out to me a similar example.

I am Pavan, an OGS user. I think this recent thread might help you.

When you use HydroMechanics, it considers the coupling effect through Biot’s poroelasticity theory. Hence, if you apply any load, excess pore pressures will definitely develop, given that you have reasonable permeability and a finite Biot coefficient. In the post I tagged above, I used a very high permeability to make the drained material wanted, as per my requirement.

Nevertheless, you will find the steps to activate effective stresses with hydrostatic gradient in the above-mentioned post.

Thanks for your kind answer. I have a question regarding your example, why did you have to ramp the density of the liquid? and how is this ramp defined? do you define it 1 at the start and 0 at the end of the simulation to simulate the dissipation of the pore pressures or is it the opposite way?

Ramping both the densities (soil, water) is a way to generate effective stresses gradually. This way, the total stresses and pore pressures are slowly set without getting the initialisation error due to the non-equilibrium of developed stresses. The ramp has been defined from 0 to 1 so that in 1 second time, the effective stresses are gradually generated under geostatic equilibrium. At later times, you can ramp loading as well as per your requirement.

Thank you again for your help, but I am a little confused, because I am also initializing the effective stress as -gamma_effective * z and the initial pore pressures as gamma_water * z and I don’t understand why I also have to ramp the densities. Or should I choose only one option? I thought with the initialization you were already defining your initial state and from that, you would start increasing the loading.

You should use any one of the approaches. If you have already initialised using the initial condition, there is no need to activate gravity (i.e., keep g = [0,0]). However, there are some pointers to note.

As you rightly said, you can initialise the stresses and pore pressures as initial conditions. This might work for a few cases. However, sometimes the larger initial residual values in FEM will result in non-equilibrium in the system, making the simulation not converge. More on this at Linear; Non-equilibrium initial states.

Regardless, the abovementioned procedure on ramping will gradually apply these stresses for geostatic equilibrium. As a matter of fact, geostatic initialisation is the first step in any commercial software (e.g., Plaxis, Abaqus). It has to be noted that giving an unstable initial stress state as an initial condition hinders the results. Ensuring the stress state is in equilibrium must be the first step before solving any BVPs. This ramping approach actually becomes handy when you are evaluating slope stability using the strength reduction method, where gravity initialisation is performed to get the failure envelope under the body forces Strength reduction for slope stability. Nonetheless, as you are dealing with flat ground, this approach is even more beneficial and straightforward as you can verify whether the effective stresses match analytically after the gravity step.

Thank you for the clarification, I thought you were increasing the density and at the same time initializing the pore pressures and the initial stresses.