CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

Create new object

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 31, 2020, 07:25
Default Create new object
  #1
Member
 
Philipp
Join Date: Feb 2019
Posts: 35
Rep Power: 7
Phigo90 is on a distinguished road
Hi Foamer,


I am trying to create a new object of the type "interfaceHeatResistance". This class inherits from the "temperaturePhaseChangeTwoPhaseMixture" class.


However, in the createFields file the object mixture is created with:
Code:
Info<< "Creating temperaturePhaseChangeTwoPhaseMixture\n" << endl;
autoPtr<temperaturePhaseChangeTwoPhaseMixture> mixture =
    temperaturePhaseChangeTwoPhaseMixture::New(thermo(), mesh);
based on


Code:
   // Selectors

        //- Return a reference to the selected phaseChange model
        static autoPtr<temperaturePhaseChangeTwoPhaseMixture> New
        (
            const thermoIncompressibleTwoPhaseMixture& mixture,
            const fvMesh& mesh
        );


    // Constructors

        //- Construct from components
        temperaturePhaseChangeTwoPhaseMixture
        (
            const thermoIncompressibleTwoPhaseMixture& mixture,
            const fvMesh& mesh
        );


    //- Destructor
    virtual ~temperaturePhaseChangeTwoPhaseMixture() = default;
Does anyone of you know how I can create an "interfaceheatresistance" object?


Code:
   // Constructors

        //- Construct from components
        interfaceHeatResistance
        (
            const thermoIncompressibleTwoPhaseMixture& mixture,
            const fvMesh& mesh
        );
I am not an expert in C++ and still learning.
Attached Files
File Type: h temperaturePhaseChangeTwoPhaseMixture.H (5.3 KB, 1 views)
File Type: h interfaceHeatResistance.H (4.9 KB, 0 views)
File Type: c interfaceHeatResistance.C (10.3 KB, 0 views)
File Type: c temperaturePhaseChangeTwoPhaseMixture.C (3.1 KB, 0 views)
File Type: h createFields.H (3.1 KB, 0 views)
Phigo90 is offline   Reply With Quote

Old   July 31, 2020, 10:38
Default
  #2
Senior Member
 
Santiago Lopez Castano
Join Date: Nov 2012
Posts: 354
Rep Power: 15
Santiago is on a distinguished road
Quote:
Originally Posted by Phigo90 View Post
Hi Foamer,


I am trying to create a new object of the type "interfaceHeatResistance". This class inherits from the "temperaturePhaseChangeTwoPhaseMixture" class.


However, in the createFields file the object mixture is created with:
Code:
Info<< "Creating temperaturePhaseChangeTwoPhaseMixture\n" << endl;
autoPtr<temperaturePhaseChangeTwoPhaseMixture> mixture =
    temperaturePhaseChangeTwoPhaseMixture::New(thermo(), mesh);
based on


Code:
   // Selectors

        //- Return a reference to the selected phaseChange model
        static autoPtr<temperaturePhaseChangeTwoPhaseMixture> New
        (
            const thermoIncompressibleTwoPhaseMixture& mixture,
            const fvMesh& mesh
        );


    // Constructors

        //- Construct from components
        temperaturePhaseChangeTwoPhaseMixture
        (
            const thermoIncompressibleTwoPhaseMixture& mixture,
            const fvMesh& mesh
        );


    //- Destructor
    virtual ~temperaturePhaseChangeTwoPhaseMixture() = default;
Does anyone of you know how I can create an "interfaceheatresistance" object?


Code:
   // Constructors

        //- Construct from components
        interfaceHeatResistance
        (
            const thermoIncompressibleTwoPhaseMixture& mixture,
            const fvMesh& mesh
        );
I am not an expert in C++ and still learning.
you are supposed to create a pointer to the thermo(...) abstract class using the selector you show (New), in order to make use of the inheritance hierarchy derived from the base class. If you create the objects directly you may induce additional overhead. It may also mess with the object registry mechanism. So in short, follow the example you just shown.
Santiago is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Foam::error::PrintStack almir OpenFOAM Running, Solving & CFD 92 Yesterday 07:56
[OpenFOAM.org] Instructions to install OpenFOAM-2.4.x on CentOS-6.10 redbullah OpenFOAM Installation 9 September 7, 2019 17:18
creating object within an object, with different field values and boundaries wernero OpenFOAM Pre-Processing 0 March 29, 2016 11:39
Actuator disk model audrich FLUENT 0 September 21, 2009 07:06
Where's the singularity/mesh flaw? audrich FLUENT 3 August 4, 2009 01:07


All times are GMT -4. The time now is 03:23.