isaar / MSolve

Open source numerical solver for computational mechanics problems
Apache License 2.0
18 stars 26 forks source link

FEM and IGA projects can be refactored into a more general discretization code #64

Closed dimtsap closed 6 years ago

dimtsap commented 6 years ago

During the porting of my code from Java to C# and MSolve specifically, I have noted that many parts of the Preprocessors apart from Elements are almost identical and thus can probably be refactored. These similar code parts can be split into the following categories:

Need abstraction

In this category belong the Entities folder of the two methods. The first reason why an abstraction is needed is that UQ/Optimization/Logging projects need to reference and alter the Model of each method. In the existing implementation, only FEM are supported while minimal changes are needed to extend the functionality. A comparison is given below:

FEM IGA
Model Model
Subdomain Patch
Element Element
Cluster Cluster
Node Control Point
NodalLoad Control Point Load

Actually, isogeometric entities can be considered as an extension of the FEM ones in most cases. In a similar fashion Faces and Edge, where Loads and Boundary Condition are applied coexist as a concept in both cases but are applied in Elements in FEM while Patches in IGA.

Identical parts after the above refactoring

Provided that Nodes - Control Points, Elements and Subdomain-Patches can be handled in a similar fashion then the following parts of code become identical and thus much code rewriting can be spared. For example interfaces and simple classes can be unified:

FEM IGA
IFiniteElementDOFEnumerator IIsogeometricDOFEnumerator
IFiniteElement IIsogeometricElement
IStructuralFiniteElement IStructuralIsogeometricElement
GenericDOFEnumerator GenericDOFEnumerator
GlobalMatrixAssemblerSkyline GlobalMatrixAssemblerSkyline

Already refactored

In this category, we had identical code such as the Materials(2D-3D etc) which had no difference between the two methods.

dimtsap commented 6 years ago

A new Discretization project has been added to the solution that unifies teh interface between FEM and IGA projects so that the same providers, analyzer etc can be used. The new project contains the following :

Integration

Interfaces

Providers

Misc classes

Please comment on Discretization project so that any parts not addressed can be included or enhance the current implementation