Initial Condition from array

8 days ago by
after read this topic I would like to know how to use an array (e.g 2D to insert in an UnitSquareMesh)  as initial condition, any  answer is going to help me a lot.
Community: FEniCS Project

1 Answer

7 days ago by

You could use the expression class...

class InitialConditionsFromArray(Expression):
    def eval_cell(self, values, x, ufc_cell):
        values[0] = self.arrayValues[ufc_cell.index][0]
        values[1] = self.arrayValues[ufc_cell.index][1]

    def __init__(self, arrayValues):
        self.arrayValues = arrayValues

Where the arrayValues passed as parameter would be an array of tuples and the index of each tuple will be assigned to the corresponding cell index ...

thanks Ihdamiani, that works!!
written 7 days ago by Ricardo Tenorio  
Please login to add an answer/comment or follow this question.

Similar posts:
Search »