|
[Sponsors] |
September 20, 2012, 12:39 |
How to add a new volField type
|
#1 |
Super Moderator
Philip Cardiff
Join Date: Mar 2009
Location: Dublin, Ireland
Posts: 1,097
Rep Power: 34 |
Hi,
I would like to create a new volField type called volTensor4thOrderField, so I have created a primitive called Tensor4thOrder and it works fine and I was able to create a tensor4thOrderField without too much difficulty. However, now I want to have a volTensor4thOrderField so I added the definition to finiteVolume/fields/volFields/volFields.C and finiteVolume/fields/volFields/volFieldsFwd.C and also for the fvPatchFields finiteVolume/fields/fvPatchField/fvPatchField/fvPatchFieldsFwd.C and finiteVolume/fields/fvPatchField/fvPatchField/fvPatchFields.C But I get lots of compilation errors to do with the fvPatchFields (basicSymmetry, fixedValue …). Does anyone have any tips or know what files exactly I might have to change to get my volTensor4thOrderField working? If it makes a difference I will be using the field for material properties so I only need the calculated or zeroGradient fvPatchField for it. Best regards, Philip |
|
September 21, 2012, 12:55 |
|
#2 |
Senior Member
David Gaden
Join Date: Apr 2009
Location: Winnipeg, Canada
Posts: 437
Rep Power: 22 |
I could be wrong, but I think it is a much more involved process than just creating the primitive and adding the lines to volFields. You may have to define template specialization behaviour for all mathematical operations. I think all this work has already been done in OpenFOAM-extend with the VectorN library. I think you can just use its VectorN with N set to however many elements there are in your tensor.
__________________
~~~ Follow me on twitter @DavidGaden |
|
September 21, 2012, 13:49 |
|
#3 |
Super Moderator
Philip Cardiff
Join Date: Mar 2009
Location: Dublin, Ireland
Posts: 1,097
Rep Power: 34 |
Hi David,
thanks for your reply. Yep it looks like I have to add a lot of things if I want it to work. I have tried the VectorN library previously but the problem is that it would not work for my purpose and would be far too memory inefficient. A fourth order tensor could be visualised as a 9x9 matrix but the definitions of the operators (dot product, double dot, etc) are not the same. Also in my case due to symmetries the fourth order tensor typically only has nine independent values, so the tensor4thOrder only stores 9 values. I think the work-around I will have to do is to store the internalField cells in a List and the boundaries in a ListList, which is a bit annoying. It would be much more elegant if I could have a volTensor4thOrderField. I will look into defining the template specialisation for all operations. Looking through the VectorN library is probably a good place to start. If you have tips, I'd love to hear. Thanks, Philip |
|
September 28, 2012, 15:35 |
|
#4 |
Senior Member
Kyle Mooney
Join Date: Jul 2009
Location: San Francisco, CA USA
Posts: 323
Rep Power: 18 |
You might be able to store it as a few vector fields (if 9 unique components perhaps 3 vector fields) and write your own operator functions.
something like: addOperator(vF1,vF2,vF3) subtractionOperator(vF1,vF2,vF3) I'd imagine writing explicit formulations would be straightforward, not so much for implicit... |
|
October 16, 2012, 17:08 |
|
#5 |
Super Moderator
Philip Cardiff
Join Date: Mar 2009
Location: Dublin, Ireland
Posts: 1,097
Rep Power: 34 |
Thanks for the suggestions,
I have been able to create a new primitive type and then create a new volField. There are many files that need to be edited in $FOAM_SRC/OpenFOAM and $FOAM_SRC/finiteVolume. For anyone else who would like to know, here are the files I had to edit: in $FOAM_SRC/OpenFOAM Code:
./BlockLduInterfaceFields.C:defineTemplateTypeNameAndDebug(BlockLduInterfaceField<sphericalTensor>, 0); ./DimensionedFields.H:#include "DimensionedSphericalTensorField.H" ./FieldFields.H:#include "sphericalTensorFieldField.H" ./GenericPointPatchField.C: == token::Compound<List<sphericalTensor> >::typeName NOT DONE RIGHT ./GenericPointPatchField.H: HashPtrTable<sphericalTensorField> sphericalTensorFields_; ./GeometricFields.H:#include "GeometricSphericalTensorField.H" ./PointPatchField.H:makePointPatchTypeFieldTypeName(typePatchField##pointPatchType##SphericalTensorField); \ ./Random.C:sphericalTensor Random::sphericalTensor01() ./Random.H: //- sphericalTensor with every component scalar01 ./dimensionedTypes.H:#include "dimensionedSphericalTensor.H" ./fieldTypes.H:#include "sphericalTensor.H" ./pointFields.C:defineTemplateTypeNameAndDebug(pointSphericalTensorField::DimensionedInternalField, 0); ./pointFieldsFwd.H:typedef GeometricField<sphericalTensor, pointPatchField, pointMesh> ./pointMesh.C: sphericalTensor, ./pointPatchFields.C:<pointPatchField, pointMesh, pointPatch, DummyMatrix, sphericalTensor> ./pointPatchFieldsFwd.H:typedef pointPatchField<sphericalTensor> pointPatchSphericalTensorField; ./primitiveFields.H:#include "sphericalTensorField.H" ./primitiveFieldsFwd.H:typedef Field<sphericalTensor> sphericalTensorField; ./symmTransform.H:inline SphericalTensor<Cmpt> transform ./transform.H:inline SphericalTensor<Cmpt> transform ./uniformDimensionedFields.C:defineTemplateTypeNameAndDebug(uniformDimensionedSphericalTensorField, 0); ./uniformDimensionedFields.H:typedef UniformDimensionedField<sphericalTensor> uniformDimensionedSphericalTensorField; ./transformField.H:99:tmp<Field<tensor4thOrder> > transformFieldMask<tensor4thOrder> Code:
AverageIOFields.C:41:typedef AverageIOField<tensor4thOrder> tensor4thOrderAverageIOField; d2dt2Scheme.H:199:makeFvD2dt2TypeScheme(SS, tensor4thOrder) d2dt2Schemes.C:49:defineTemplateRunTimeSelectionTable(d2dt2Scheme<tensor4thOrder>, Istream); ddtScheme.H:259:makeFvDdtTypeScheme(SS, tensor4thOrder) \ ddtSchemes.C:49:defineTemplateRunTimeSelectionTable(ddtScheme<tensor4thOrder>, Istream); divScheme.H:182:makeFvDivTypeScheme(SS, tensor4thOrder) \ divSchemes.C:65: divScheme<tensor4thOrder>, fvMatrices.C:43:defineTemplateTypeNameAndDebug(fvTensor4thOrderMatrix, 0); fvMatricesFwd.H:55:typedef fvMatrix<tensor4thOrder> fvTensor4thOrderMatrix; fvMesh.C:446: MapGeometricFields<tensor4thOrder, fvPatchField, fvMeshMapper, volMesh> fvPatchField.H:501:makePatchTypeFieldTypeName(type##FvPatchTensor4thOrderField); \ fvPatchFields.C:52:makeFvPatchField(fvPatchTensor4thOrderField) fvPatchFieldsFwd.H:45:typedef fvPatchField<tensor4thOrder> fvPatchTensor4thOrderField; fvsPatchField.H:390:makeFvsPatchTypeFieldTypeName(type##FvsPatchTensor4thOrderField); \ fvsPatchFields.C:52:makeFvsPatchField(fvsPatchTensor4thOrderField) fvsPatchFieldsFwd.H:50:typedef fvsPatchField<tensor4thOrder> fvsPatchTensor4thOrderField; genericFvPatchField.C:503: HashPtrTable<tensor4thOrderField>::const_iterator iter = genericFvPatchField.H:65: HashPtrTable<tensor4thOrderField> tensor4thOrderFields_; interpolation.H:161:makeInterpolationType(SS, tensor4thOrder) \ interpolations.C:43:defineTemplateRunTimeSelectionTable(interpolation<tensor4thOrder>, dictionary); limitedSurfaceInterpolationScheme.H:227:makelimitedSurfaceInterpolationTypeScheme(SS, tensor4thOrder) limitedSurfaceInterpolationSchemes.C:56:makeBaseLimitedSurfaceInterpolationScheme(tensor4thOrder) slicedSurfaceFieldsFwd.H:76:SlicedGeometricField<tensor4thOrder, fvsPatchField, slicedFvsPatchField, surfaceMesh> slicedVolFieldsFwd.H:77:SlicedGeometricField<tensor4thOrder, fvPatchField, slicedFvPatchField, volMesh> snGradScheme.H:198:makeSnGradTypeScheme(SS, tensor4thOrder) snGradSchemes.C:50:defineTemplateRunTimeSelectionTable(snGradScheme<tensor4thOrder>, Mesh); surfaceFields.C:40:defineTemplateTypeNameAndDebug(surfaceTensor4thOrderField::DimensionedInternalField, 0); surfaceFieldsFwd.H:61:typedef GeometricField<tensor4thOrder, fvsPatchField, surfaceMesh> surfaceInterpolationScheme.H:230:makeSurfaceInterpolationTypeScheme(SS, tensor4thOrder) \ surfaceInterpolationSchemes.C:56:makeBaseSurfaceInterpolationScheme(tensor4thOrder) volFields.C:40:defineTemplateTypeNameAndDebug(volTensor4thOrderField::DimensionedInternalField, 0); volFieldsFwd.H:60:typedef GeometricField<tensor4thOrder, fvPatchField, volMesh> volTensor4thOrderField; Code:
./DimensionedSphericalTensorField.C:#include "DimensionedSphericalTensorField.H" ./DimensionedSphericalTensorField.H: Foam::DimensionedSphericalTensorField ./GeometricSphericalTensorField.C:#include "GeometricSphericalTensorField.H" ./GeometricSphericalTensorField.H: Foam::GeometricSphericalTensorField ./SphericalTensor.H: Foam::SphericalTensor ./SphericalTensorI.H:inline SphericalTensor<Cmpt>::SphericalTensor() ./dimensionedSphericalTensor.C: Dimensioned sphericalTensor obtained from generic dimensioned type. ./dimensionedSphericalTensor.H:dimensionedSphericalTensor inv(const dimensionedSphericalTensor&); ./labelSphericalTensor.C:#include "labelSphericalTensor.H" ./labelSphericalTensor.H:inline bool contiguous<labelSphericalTensor>() {return true;} ./sphericalTensor.C:#include "sphericalTensor.H" ./sphericalTensor.H: Foam::sphericalTensor ./sphericalTensorField.C:#include "sphericalTensorField.H" ./sphericalTensorField.H: Foam::sphericalTensorField ./sphericalTensorFieldField.C: Specialisation of FieldField<Field, T> for sphericalTensor. ./sphericalTensorFieldField.H: Foam::sphericalTensorFieldField ./sphericalTensorIOField.C: sphericalTensorField with IO. ./sphericalTensorIOField.H: Foam::sphericalTensorIOField ./sphericalTensorList.C: Specialisation of List\<T\> for sphericalTensor. ./sphericalTensorList.H: Foam::sphericalTensorList Phew, and that's it! Philip |
|
May 17, 2016, 09:01 |
|
#6 |
New Member
Zhoujiang Deng
Join Date: May 2016
Posts: 3
Rep Power: 10 |
Dear Philip,
Could you explain some details about how to generate a new volTensor4thOrderfield in OpenFOAM? Thanks for your work here!! I also need this volTensor4thOrderfield to generate a tensor regarding elastoplastic stress strain relationship. Thank you very much!! Best Regards Zhoujiang Deng |
|
May 17, 2016, 09:02 |
|
#7 |
New Member
Zhoujiang Deng
Join Date: May 2016
Posts: 3
Rep Power: 10 |
Dear Philip,
Could you explain some details about how to generate a new volTensor4thOrderfield in OpenFOAM? Thanks for your work here!! I also need this volTensor4thOrderfield to generate a tensor regarding elastoplastic stress strain relationship. Thank you very much!! Best Regards Zhoujiang Deng |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[swak4Foam] GroovyBC the dynamic cousin of funkySetFields that lives on the suburb of the mesh | gschaider | OpenFOAM Community Contributions | 300 | October 29, 2014 19:00 |
[swak4Foam] Air Conditioned room groovyBC | Sebaj | OpenFOAM Community Contributions | 7 | October 31, 2012 15:16 |
[Other] cgnsToFoam problems with "QUAD_4" cells | lentschi | OpenFOAM Meshing & Mesh Conversion | 1 | March 9, 2011 05:49 |
turbulent jet simulation | antonio_ing | OpenFOAM Running, Solving & CFD | 5 | September 16, 2010 03:31 |
reconstructParMesh not working with an axisymetric case | francesco | OpenFOAM Bugs | 4 | May 8, 2009 06:49 |